Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 0 additions & 46 deletions .github/workflows/check-pr-size.yml

This file was deleted.

35 changes: 1 addition & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/internxt/node-win)

# Setup

This guide explains how to set up and build the `node-win` project.

## Prerequisites

Before proceeding, ensure you have the following tools installed:

- **Python 3.10**
- **Node 20**

```bash
nvm install 20
```

- **node-gyp**

```bash
npm install -g node-gyp
```

- **Visual Studio** (not VS Code) for building native dependencies.

## Build Steps

Run the following command to build the project:

```bash
npm run build
```

This step compiles the necessary native bindings.
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/internxt/node-win)
2 changes: 0 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"native-src/sync_root_interface/callbacks/FetchData/FetchData.cpp",
"native-src/sync_root_interface/callbacks/FetchData/FileCopierWithProgress.cpp",
"native-src/sync_root_interface/callbacks/FetchData/TransferContext.cpp",
"native-src/sync_root_interface/callbacks/FetchPlaceholder/FetchPlaceholder.cpp",
"native-src/sync_root_interface/callbacks/NotifyDelete/NotifyDeleteCallback.cpp",
"native-src/virtual_drive/Wrappers.cpp"
],
"include_dirs": [
Expand Down
Binary file modified dist/addon.node
Binary file not shown.
2 changes: 0 additions & 2 deletions include/placeholders_interface/Placeholders.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class Placeholders
static void UpdateSyncStatus(const std::wstring &filePath, bool syncState, bool isDirectory);
static HRESULT UpdatePinState(const std::wstring &path, const PinState state);
static CF_PLACEHOLDER_STATE GetPlaceholderState(const std::wstring &filePath);
static std::vector<std::wstring> GetPlaceholderWithStatePending(const std::wstring &filePath);
static bool IsFileValidForSync(const std::wstring &filePath);
static PlaceholderResult ConvertToPlaceholder(const std::wstring &fullPath, const std::wstring &serverIdentity);
static std::string GetFileIdentity(const std::wstring &filePath);
static void UpdateFileIdentity(const std::wstring &filePath, const std::wstring &fileIdentity, bool isDirectory);
Expand Down
8 changes: 0 additions & 8 deletions include/sync_root_interface/callbacks/Callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

void register_threadsafe_callbacks(napi_env env, InputSyncCallbacks input);

// Notify Delete Callback
void register_threadsafe_notify_delete_callback(const std::string &resource_name, napi_env env, InputSyncCallbacks input);
void CALLBACK notify_delete_callback_wrapper(_In_ CONST CF_CALLBACK_INFO *callbackInfo, _In_ CONST CF_CALLBACK_PARAMETERS *callbackParameters);

// Fetch Placeholders Callback
void register_threadsafe_fetch_placeholders_callback(const std::string &resource_name, napi_env env, InputSyncCallbacks input);
void CALLBACK fetch_placeholders_callback_wrapper(_In_ CONST CF_CALLBACK_INFO *callbackInfo, _In_ CONST CF_CALLBACK_PARAMETERS *callbackParameters);

// Fetch Data Callback
void register_threadsafe_fetch_data_callback(const std::string &resource_name, napi_env env, InputSyncCallbacks input);
void CALLBACK fetch_data_callback_wrapper(_In_ CONST CF_CALLBACK_INFO *callbackInfo, _In_ CONST CF_CALLBACK_PARAMETERS *callbackParameters);
Expand Down
10 changes: 0 additions & 10 deletions include/sync_root_interface/callbacks/CallbacksContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,5 @@

struct InputSyncCallbacks {
napi_ref fetch_data_callback_ref;
napi_ref validate_data_callback_ref;
napi_ref cancel_fetch_data_callback_ref;
napi_ref fetch_placeholders_callback_ref;
napi_ref cancel_fetch_placeholders_callback_ref;
napi_ref notify_file_open_completion_callback_ref;
napi_ref notify_file_close_completion_callback_ref;
napi_ref notify_dehydrate_callback_ref;
napi_ref notify_dehydrate_completion_callback_ref;
napi_ref notify_delete_callback_ref;
napi_ref notify_delete_completion_callback_ref;
napi_ref none_callback_ref;
};
1 change: 0 additions & 1 deletion include/virtual_drive/Wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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 DeleteFileSyncRootWrapper(napi_env env, napi_callback_info args);
napi_value UpdateFileIdentityWrapper(napi_env env, napi_callback_info args);
Expand Down
17 changes: 0 additions & 17 deletions native-src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,6 @@ napi_value init(napi_env env, napi_value exports)
return nullptr;
}

napi_property_descriptor getPlaceholderWithStatePendingDesc = {
"getPlaceholderWithStatePending",
nullptr,
GetPlaceholderWithStatePendingWrapper,
nullptr,
nullptr,
nullptr,
napi_default,
nullptr};

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

napi_property_descriptor convertToPlaceholderDesc = {
"convertToPlaceholder",
nullptr,
Expand Down
93 changes: 0 additions & 93 deletions native-src/placeholders_interface/Planceholders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,99 +493,6 @@ FileState Placeholders::GetPlaceholderInfo(const std::wstring &directoryPath)
return fileState;
}

std::vector<std::wstring> Placeholders::GetPlaceholderWithStatePending(const std::wstring &directoryPath)
{
std::vector<std::wstring> resultPaths;

try
{
for (const auto &entry : std::filesystem::directory_iterator(directoryPath, std::filesystem::directory_options::skip_permission_denied))
{
const auto &path = entry.path().wstring();

if (entry.is_directory())
{
FileState folderState = Placeholders::GetPlaceholderInfo(path);

if (folderState.syncstate == SyncState::Undefined || folderState.syncstate == SyncState::NotInSync)
{
std::vector<std::wstring> subfolderPaths = GetPlaceholderWithStatePending(path);
resultPaths.insert(resultPaths.end(), subfolderPaths.begin(), subfolderPaths.end());
}
}
else if (entry.is_regular_file())
{
FileState placeholderState = Placeholders::GetPlaceholderInfo(path);

bool isFileValidForSync = (placeholderState.syncstate == SyncState::Undefined || placeholderState.syncstate == SyncState::NotInSync);
if (isFileValidForSync && IsFileValidForSync(path))
{
resultPaths.push_back(path);
}
}
}
}
catch (const std::exception &e)
{
wprintf(L"[GetPlaceholderWithStatePending] Error: %s\n", e.what());
}

return resultPaths;
}
bool Placeholders::IsFileValidForSync(const std::wstring &filePath)
{
// Obtener un handle al archivo
HANDLE fileHandle = CreateFileW(
filePath.c_str(),
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr);

if (fileHandle == INVALID_HANDLE_VALUE)
{
// No se pudo abrir el archivo
return false;
}

// Verificar si el archivo está vacío
LARGE_INTEGER fileSize;
if (!GetFileSizeEx(fileHandle, &fileSize))
{
CloseHandle(fileHandle);
return false;
}

if (fileSize.QuadPart == 0)
{
CloseHandle(fileHandle);
return false;
}

LARGE_INTEGER maxFileSize;
maxFileSize.QuadPart = 40LL * 1024 * 1024 * 1024; // 20GB

if (fileSize.QuadPart > maxFileSize.QuadPart)
{
CloseHandle(fileHandle);
return false;
}

// // Verificar la extensión del archivo
if (std::filesystem::path(filePath).extension().empty())
{
CloseHandle(fileHandle);
return false;
}

// Cerrar el handle del archivo
CloseHandle(fileHandle);

return true;
}

void Placeholders::ForceShellRefresh(const std::wstring &path)
{
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, path.c_str(), nullptr);
Expand Down
2 changes: 0 additions & 2 deletions native-src/sync_root_interface/SyncRoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ HRESULT SyncRoot::ConnectSyncRoot(const wchar_t *syncRootPath, InputSyncCallback
TransformInputCallbacksToSyncCallbacks(env, syncCallbacks);

CF_CALLBACK_REGISTRATION callbackTable[] = {
{CF_CALLBACK_TYPE_NOTIFY_DELETE, notify_delete_callback_wrapper},
{CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS, fetch_placeholders_callback_wrapper},
{CF_CALLBACK_TYPE_FETCH_DATA, fetch_data_callback_wrapper},
{CF_CALLBACK_TYPE_CANCEL_FETCH_DATA, cancel_fetch_data_callback_wrapper},
CF_CALLBACK_REGISTRATION_END};
Expand Down
1 change: 0 additions & 1 deletion native-src/sync_root_interface/callbacks/Callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

void register_threadsafe_callbacks(napi_env env, InputSyncCallbacks input)
{
register_threadsafe_notify_delete_callback("NotifyDeleteThreadSafe", env, input);
register_threadsafe_fetch_data_callback("FetchDataThreadSafe", env, input);
register_threadsafe_cancel_fetch_data_callback("CancelFetchDataThreadSafe", env, input);
}

This file was deleted.

Loading