Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-1737]: Feat/rebranding pccloud #73

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c65a048
wip: add logger info to know the procecss to get items
migueldesarrollosoftware Mar 12, 2024
92ffe26
wip: modify get items ids using basic info
migueldesarrollosoftware Mar 13, 2024
a89c864
feat: modify register provider
migueldesarrollosoftware Mar 14, 2024
628ca2a
feat: get items as itemsInfo
migueldesarrollosoftware Mar 14, 2024
8ebb477
feat: getFileidenty by path completed
migueldesarrollosoftware Mar 14, 2024
f9e1f06
feat: clean chars unnecesary
migueldesarrollosoftware Mar 14, 2024
50f70f8
debug comments
migueldesarrollosoftware Mar 15, 2024
7effbb3
not use logger file
migueldesarrollosoftware Mar 15, 2024
a761976
comment file1
Mar 15, 2024
2cbe168
Merge branch 'feat/get-fileidentity-by-path' of github.com:internxt/n…
Mar 15, 2024
a525fca
increase buffer size
migueldesarrollosoftware Mar 15, 2024
d6e7319
Merge branch 'feat/get-fileidentity-by-path' of github.com:internxt/n…
Mar 15, 2024
5b022ba
add delete file funtion
Mar 15, 2024
95bad88
modify craetion of placeholder
migueldesarrollosoftware Mar 15, 2024
151080a
merge
migueldesarrollosoftware Mar 15, 2024
d8d2a1c
Merge pull request #75 from internxt/feat/get-fileidentity-by-path
miguelsw Mar 15, 2024
424992f
delete recursivo
migueldesarrollosoftware Mar 15, 2024
6c254d8
remove all filefolders
migueldesarrollosoftware Mar 15, 2024
9631ef8
Merge branch 'fix/placeholder-creation' of github.com:internxt/node-w…
migueldesarrollosoftware Mar 15, 2024
ebc7cb8
feat: reimplement get identity
cg27shokworks Mar 17, 2024
a555b49
fix: remove comments
migueldesarrollosoftware Mar 18, 2024
38a32e4
Merge branch 'fix/placeholder-creation' of github.com:internxt/node-w…
migueldesarrollosoftware Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 83 additions & 3 deletions examples/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,33 @@ try {
fileCreatedAt,
fileUpdatedAt
);

drive.createFolderByPath(
`/carpetaX`,
"folder-f134-4dbd-8722-8f813ec412cf",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFileByPath(
`/file1.txt`,
`/carpetaX/file1.txt`,
"8bb39aa1-4791-4505-998d-7d47379d10e4",
1000,
fileCreatedAt,
fileUpdatedAt
);

drive.createFolderByPath(
`/anyname`,
"192391023-4791-4505-998d-7d47379d10e4",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFileByPath(
`/folderWithFile/file2.txt`,
`/anyname/file2.txt`,
"8eeadacd-6c94-40b4-b78c-067370386e95",
1000,
fileCreatedAt,
Expand Down Expand Up @@ -87,13 +105,47 @@ try {
folderCreatedAt,
folderUpdatedAt
);
drive.createFolderByPath(
`/folderT`,
"folder-f134-4dbd-8722-8f813ec412cf",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFolderByPath(
`/folderT/folderA`,
"folder-54343-4dbd-8722-8f813ec412cf",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFolderByPath(
`/folderT/folderA/folderB`,
"folder-465t-4dbd-8722-8f813ec412cf",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFolderByPath(
`/F.O.L.D.E.R`,
"2d6bce9b-d006-412d-9a98-8c5fac2ad6e5",
1000,
folderCreatedAt,
folderUpdatedAt
);

drive.createFolderByPath(
`/folderWithFolder`,
`folder-8a0e-43cb-805b-2719a686358f`,
1000,
folderCreatedAt,
folderUpdatedAt
);


drive.createFolderByPath(
`/folderWithFolder/folder2`,
"f706369a-8a0e-43cb-805b-2719a686358f",
Expand Down Expand Up @@ -124,14 +176,22 @@ try {
fileCreatedAt,
fileUpdatedAt
);
// /folderWithFolder/F.O.L.D.E.R
drive.createFileByPath(
`/folderWithFolder/F.O.L.D.E.R/unaImagen.rar`,
"62654a1c-0137-4fc7-b271-2c62f0d6f9f5",
33020,
fileCreatedAt,
fileUpdatedAt
);

// this part of example emulate the server ( createFilesWithSize ) and a storage layer ( ItemsInfoManager )
createFilesWithSize(settings.syncRootPath, settings.serverRootPath);

const itemsManager = ItemsInfoManager.initialize().then((itemsManager) => {
itemsManager.add({
"485df926-c07c-4a4c-a23b-e2b8e8d41988": `${settings.serverRootPath}\\A (5th copy).pdfs`,
"8bb39aa1-4791-4505-998d-7d47379d10e4": `${settings.serverRootPath}\\file1.txt`,
// "8bb39aa1-4791-4505-998d-7d47379d10e4": `${settings.serverRootPath}\\file1.txt`,
"8eeadacd-6c94-40b4-b78c-067370386e95": `${settings.serverRootPath}\\file2.txt`,
"8d2d85b1-b725-42eb-ac46-d5b2a90c57ea": `${settings.serverRootPath}\\fakefile.txt`,
"03f7c464-3cf9-4664-9a79-078440cfac41": `${settings.serverRootPath}\\imagen.rar`,
Expand All @@ -152,6 +212,26 @@ try {
"3c598981-bca6-40ca-b016-fe2c0cdc5baf"
);


drive.getFileIdentity("/folderWithFolder/F.O.L.D.E.R").then((fileIdentity) => {
console.log("ID " +fileIdentity);
console.log("count " + String(fileIdentity).length);
})

drive.getFileIdentity("/folderWithFolder").then((fileIdentity) => {
console.log("ID " +fileIdentity);
console.log("count " + String(fileIdentity).length);
})

drive.getFileIdentity("/folderWithFolder/F.O.L.D.E.R/unaImagen.rar").then((fileIdentity) => {
console.log("ID " +fileIdentity);
console.log("count " + String(fileIdentity).length);
})

// drive.deleteFileSyncRoot("/folderWithFolder");
// drive.deleteFileSyncRoot("/imagen.rar");
// drive.deleteFileSyncRoot("/anyname");

console.log(success2);

drive.watchAndWait(settings.syncRootPath);
Expand Down
11 changes: 8 additions & 3 deletions include/placeholders_interface/PlaceHolderInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#include "stdafx.h"
#include <optional>

enum class SyncState {
enum class SyncState
{
/* status that occurs when an error occurs while reading the status*/
Undefined = -1,
NotInSync = 0,
InSync = 1,
};

enum class PinState {
enum class PinState
{
/* The pin state is derived from the state of the parent folder. For example new remote files start out in this state, following the state of their parent folder. This state is used purely for resetting pin states to their derived value. The effective state for an item will never be "Inherited". */
Inherited = 0,
/* The file shall be available and up to date locally. Also known as "pinned". Pinned dehydrated files shall be hydrated as soon as possible. */
Expand All @@ -37,6 +39,8 @@ class PlaceHolderInfo

std::optional<PinState> pinState() const;
std::optional<SyncState> syncState() const;
std::optional<LARGE_INTEGER> FileId() const;
std::optional<BYTE> FileIdentity() const;

private:
std::unique_ptr<CF_PLACEHOLDER_BASIC_INFO, Deleter> _data;
Expand All @@ -52,9 +56,10 @@ class FileHandle

inline void *get() const { return _data.get(); }
inline explicit operator bool() const noexcept { return static_cast<bool>(_data); }
static void deletePlaceholderInfo(CF_PLACEHOLDER_BASIC_INFO *data);

private:
std::unique_ptr<void, void(*)(void *)> _data;
std::unique_ptr<void, void (*)(void *)> _data;
};

FileHandle handleForPath(const std::wstring &path);
Expand Down
1 change: 1 addition & 0 deletions include/placeholders_interface/Placeholders.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ class Placeholders
static std::vector<std::wstring> GetPlaceholderWithStatePending(const std::wstring& filePath);
static bool IsFileValidForSync(const std::wstring& filePath);
static bool ConvertToPlaceholder(const std::wstring& fullPath, const std::wstring& serverIdentity);
static std::string GetFileIdentity(const std::wstring& filePath);
};
12 changes: 11 additions & 1 deletion include/sync_root_interface/SyncRoot.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

#include <cfapi.h>
#include <Callbacks.h>
#include "stdafx.h"

struct ItemInfo
{
std::wstring path;
std::wstring fileIdentity;
bool isPlaceholder;
};

class SyncRoot
{
Expand All @@ -10,5 +18,7 @@ class SyncRoot
static HRESULT ConnectSyncRoot(const wchar_t *syncRootPath, InputSyncCallbacks syncCallbacks, napi_env env, CF_CONNECTION_KEY *connectionKey);
static HRESULT DisconnectSyncRoot();
static HRESULT UnregisterSyncRoot();
static HRESULT GetItemsSyncRoot(const wchar_t *syncRootPath, std::vector<std::wstring> &getFileIdentities);
static std::list<ItemInfo> GetItemsSyncRoot(const wchar_t *syncRootPath);
static std::string GetFileIdentity(const wchar_t *path);
static void DeleteFileSyncRoot(const wchar_t *path);
};
14 changes: 14 additions & 0 deletions include/sync_root_interface/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ class Utilities
info->ConnectionKey,
info->TransferKey};
}

static DWORD convertSizeToDWORD(size_t &convertVar)
{
if (convertVar > UINT_MAX)
{
convertVar = UINT_MAX;
}
return static_cast<DWORD>(convertVar);
}

static DWORD sizeToDWORD(size_t size)
{
return convertSizeToDWORD(size);
}
};
2 changes: 2 additions & 0 deletions include/virtual_drive/Wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ napi_value WatchAndWaitWrapper(napi_env env, napi_callback_info args);
napi_value CreateEntryWrapper(napi_env env, napi_callback_info args);
napi_value DisconnectSyncRootWrapper(napi_env env, napi_callback_info args);
napi_value GetItemsSyncRootWrapper(napi_env env, napi_callback_info args);
napi_value GetFileIdentityWrapper(napi_env env, napi_callback_info args);
napi_value addLoggerPathWrapper(napi_env env, napi_callback_info args);
napi_value UpdateSyncStatusWrapper(napi_env env, napi_callback_info args);
napi_value GetPlaceholderStateWrapper(napi_env env, napi_callback_info args);
napi_value GetPlaceholderWithStatePendingWrapper(napi_env env, napi_callback_info args);
napi_value ConvertToPlaceholderWrapper(napi_env env, napi_callback_info args);
napi_value CloseMutexWrapper(napi_env env, napi_callback_info args);
napi_value DeleteFileSyncRootWrapper(napi_env env, napi_callback_info args);
38 changes: 36 additions & 2 deletions native-src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ napi_value init(napi_env env, napi_value exports)
return nullptr;
}

napi_property_descriptor getItemsDesc{
napi_property_descriptor getItemsIdsDesc{
"getItemsIds",
nullptr,
GetItemsSyncRootWrapper,
Expand All @@ -138,13 +138,47 @@ napi_value init(napi_env env, napi_value exports)
napi_default,
nullptr};

napi_status defineGetItemsStatus = napi_define_properties(env, exports, 1, &getItemsDesc);
napi_status defineGetItemsStatus = napi_define_properties(env, exports, 1, &getItemsIdsDesc);
if (defineGetItemsStatus != napi_ok)
{
napi_throw_error(env, nullptr, "Failed to define GetItemsSyncRoot function");
return nullptr;
}

napi_property_descriptor getFileIdentityDesc = {
"getFileIdentity",
nullptr,
GetFileIdentityWrapper,
nullptr,
nullptr,
nullptr,
napi_default,
nullptr};

napi_status defineGetFileIdentityStatus = napi_define_properties(env, exports, 1, &getFileIdentityDesc);
if (defineGetFileIdentityStatus != napi_ok)
{
napi_throw_error(env, nullptr, "Failed to define getFileIdentity function");
return nullptr;
}

napi_property_descriptor deleteFileSyncRootDesc = {
"deleteFileSyncRoot",
nullptr,
DeleteFileSyncRootWrapper,
nullptr,
nullptr,
nullptr,
napi_default,
nullptr};

napi_status deleteFileSyncRootStatus = napi_define_properties(env, exports, 1, &deleteFileSyncRootDesc);
if (deleteFileSyncRootStatus != napi_ok)
{
napi_throw_error(env, nullptr, "Failed to define getFileIdentity function");
return nullptr;
}

napi_property_descriptor addLoggerPathDesc = {
"addLoggerPath",
nullptr,
Expand Down
Loading