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
5 changes: 0 additions & 5 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
"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/sync_root_interface/callbacks/NotifyFileAdded/NotifyFileAddedCallback.cpp",
"native-src/sync_root_interface/callbacks/NotifyMessage/NofifyMessageCallback.cpp",
"native-src/sync_root_interface/callbacks/NotifyRename/NotifyRenameCallback.cpp",
"native-src/sync_root_watcher/DirectoryWatcher.cpp",
"native-src/sync_root_watcher/SyncRootWatcher.cpp",
"native-src/virtual_drive/Wrappers.cpp"
],
"include_dirs": [
Expand All @@ -41,7 +37,6 @@
"include/placeholders_interface",
"include/sync_root_interface",
"include/sync_root_interface/callbacks",
"include/sync_root_watcher",
"include/types",
"include/virtual_drive"
],
Expand Down
5 changes: 4 additions & 1 deletion include/placeholders_interface/PlaceHolderInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ enum class PinState
Excluded = 4,
};


struct FileState {
PinState pinstate;
SyncState syncstate;
};

class PlaceHolderInfo
{
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 @@ -48,4 +48,5 @@ class Placeholders
static std::string GetFileIdentity(const std::wstring &filePath);
static void UpdateFileIdentity(const std::wstring &filePath, const std::wstring &fileIdentity, bool isDirectory);
static PlaceholderAttribute GetAttribute(const std::wstring &filePath);
static FileState GetPlaceholderInfo(const std::wstring &directoryPath);
};
1 change: 1 addition & 0 deletions include/sync_root_interface/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Utilities
static void ApplyCustomOverwriteStateToPlaceholderFile(_In_ LPCWSTR path, _In_ LPCWSTR filename, _In_ winrt::StorageProviderItemProperty &prop);
static std::wstring ProcessErrorNameToWString(_In_ ProcessErrorName error);
static std::wstring FileOperationErrorToWString(_In_ FileOperationError error);
static bool IsTemporaryFile(const std::wstring &fullPath);

static winrt::com_array<wchar_t>
ConvertSidToStringSid(_In_ PSID sid)
Expand Down
9 changes: 0 additions & 9 deletions include/sync_root_interface/callbacks/Callbacks.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <CallbacksContext.h>
#include "DirectoryWatcher.h"

void register_threadsafe_callbacks(napi_env env, InputSyncCallbacks input);

Expand All @@ -24,11 +23,3 @@ void CALLBACK fetch_data_callback_wrapper(_In_ CONST CF_CALLBACK_INFO *callbackI
// Fetch Data Cancel Callback
void register_threadsafe_cancel_fetch_data_callback(const std::string &resource_name, napi_env env, InputSyncCallbacks input);
void CALLBACK cancel_fetch_data_callback_wrapper(_In_ CONST CF_CALLBACK_INFO *callbackInfo, _In_ CONST CF_CALLBACK_PARAMETERS *callbackParameters);

// Notify File Added Callback. This is a fake callback
void notify_file_added_call(napi_env env, napi_value js_callback, void *context, void *data);
void register_threadsafe_notify_file_added_callback(FileChange &change, const std::string &resource_name, napi_env env, InputSyncCallbacksThreadsafe input);

// Notify message from node-win
void notify_message_call(napi_env env, napi_value js_callback, void *context, void *data);
void register_threadsafe_message_callback(FileChange &change, const std::string &resource_name, napi_env env, InputSyncCallbacksThreadsafe input);
64 changes: 0 additions & 64 deletions include/sync_root_watcher/DirectoryWatcher.h

This file was deleted.

46 changes: 0 additions & 46 deletions include/sync_root_watcher/DownloadMutexManager.h

This file was deleted.

44 changes: 0 additions & 44 deletions include/sync_root_watcher/SyncRootWatcher.h

This file was deleted.

2 changes: 0 additions & 2 deletions include/virtual_drive/Wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ napi_value CreatePlaceholderFile(napi_env env, napi_callback_info args);
napi_value UnregisterSyncRootWrapper(napi_env env, napi_callback_info args);
napi_value RegisterSyncRootWrapper(napi_env env, napi_callback_info args);
napi_value ConnectSyncRootWrapper(napi_env env, napi_callback_info args);
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 GetFileIdentityWrapper(napi_env env, napi_callback_info args);
Expand All @@ -15,7 +14,6 @@ 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);
napi_value UpdateFileIdentityWrapper(napi_env env, napi_callback_info args);
napi_value DehydrateFileWrapper(napi_env env, napi_callback_info args);
Expand Down
35 changes: 0 additions & 35 deletions native-src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@

napi_value init(napi_env env, napi_value exports)
{
// Watcher
napi_property_descriptor watchAndWaitDesc = {
"watchAndWait", // nombre de la función en JS
nullptr,
WatchAndWaitWrapper, // nombre de tu función en C++
nullptr,
nullptr,
nullptr,
napi_default,
nullptr};

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

// CreatePlaceholderFileWrapper
napi_property_descriptor desc = {
"createPlaceholderFile",
Expand Down Expand Up @@ -247,23 +229,6 @@ napi_value init(napi_env env, napi_value exports)
return nullptr;
}

napi_property_descriptor closeMutexDesc = {
"closeMutex",
nullptr,
CloseMutexWrapper,
nullptr,
nullptr,
nullptr,
napi_default,
nullptr};

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

napi_property_descriptor updateFileIdentityDesc = {
"updateFileIdentity",
nullptr,
Expand Down
65 changes: 63 additions & 2 deletions native-src/placeholders_interface/Planceholders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "PlaceholderInfo.h"
#include <winrt/base.h>
#include <shlwapi.h>
#include "SyncRootWatcher.h"
#include <vector>
#include <filesystem>
#include <fstream>
Expand Down Expand Up @@ -451,6 +450,68 @@ CF_PLACEHOLDER_STATE GetPlaceholderStateMock(const std::wstring &filePath)
}
}


FileState Placeholders::GetPlaceholderInfo(const std::wstring &directoryPath)
{

constexpr auto fileIdMaxLength = 400;
const auto infoSize = sizeof(CF_PLACEHOLDER_BASIC_INFO) + fileIdMaxLength;
auto info = PlaceHolderInfo(reinterpret_cast<CF_PLACEHOLDER_BASIC_INFO *>(new char[infoSize]), FileHandle::deletePlaceholderInfo);

FileState fileState;
auto fileHandle = handleForPath(directoryPath);

if (!fileHandle)
{
printf("Error: Invalid file handle.\n");
fileState.pinstate = PinState::Unspecified;
fileState.syncstate = SyncState::Undefined;
return fileState;
}

HRESULT result = CfGetPlaceholderInfo(fileHandle.get(), CF_PLACEHOLDER_INFO_BASIC, info.get(), Utilities::sizeToDWORD(infoSize), nullptr);

if (result != S_OK)
{
printf("CfGetPlaceholderInfo failed with HRESULT %lx\n", result);
fileState.pinstate = PinState::Unspecified;
fileState.syncstate = SyncState::Undefined;
return fileState;
}

auto pinStateOpt = info.pinState();
auto syncStateOpt = info.syncState();

if (syncStateOpt.has_value())
{

SyncState syncState = syncStateOpt.value();

printf("placeholderInfo.SyncState: %s\n", syncStateToString(syncState).c_str());
}
else
{
printf("placeholderInfo.SyncState: No value\n");
}

if (pinStateOpt.has_value())
{

PinState pinState = pinStateOpt.value();

printf("placeholderInfo.PinState: %s\n", pinStateToString(pinState).c_str());
}
else
{
printf("placeholderInfo.PinState: No value\n");
}

fileState.pinstate = pinStateOpt.value_or(PinState::Unspecified);
fileState.syncstate = syncStateOpt.value_or(SyncState::Undefined);

return fileState;
}

std::vector<std::wstring> Placeholders::GetPlaceholderWithStatePending(const std::wstring &directoryPath)
{
std::vector<std::wstring> resultPaths;
Expand All @@ -466,7 +527,7 @@ std::vector<std::wstring> Placeholders::GetPlaceholderWithStatePending(const std
}
else if (entry.is_regular_file())
{
FileState placeholderState = DirectoryWatcher::getPlaceholderInfo(path);
FileState placeholderState = Placeholders::GetPlaceholderInfo(path);
bool isFileValidForSync = (placeholderState.syncstate == SyncState::Undefined || placeholderState.syncstate == SyncState::NotInSync);
if (isFileValidForSync && IsFileValidForSync(path))
{
Expand Down
1 change: 0 additions & 1 deletion native-src/sync_root_interface/SyncRoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <iostream>
#include <filesystem>
#include "Logger.h"
#include "DownloadMutexManager.h"

namespace fs = std::filesystem;
// variable to disconect
Expand Down
Loading