diff --git a/dist/addon.node b/dist/addon.node index 5a6f75cc..431044c6 100644 Binary files a/dist/addon.node and b/dist/addon.node differ diff --git a/include/sync_root_interface/SyncRoot.h b/include/sync_root_interface/SyncRoot.h index af4860fd..d5752d58 100644 --- a/include/sync_root_interface/SyncRoot.h +++ b/include/sync_root_interface/SyncRoot.h @@ -29,6 +29,7 @@ class SyncRoot static HRESULT ConnectSyncRoot(const wchar_t *syncRootPath, InputSyncCallbacks syncCallbacks, napi_env env, CF_CONNECTION_KEY *connectionKey); static HRESULT DisconnectSyncRoot(const wchar_t *syncRootPath); static HRESULT UnregisterSyncRoot(const GUID &providerId); + static HRESULT UnregisterSyncRoot(const wchar_t *providerIdStr); static std::string GetFileIdentity(const wchar_t *path); static void HydrateFile(const wchar_t *filePath); static void DehydrateFile(const wchar_t *filePath); diff --git a/native-src/sync_root_interface/SyncRoot.cpp b/native-src/sync_root_interface/SyncRoot.cpp index a72d7512..fd6fefd8 100644 --- a/native-src/sync_root_interface/SyncRoot.cpp +++ b/native-src/sync_root_interface/SyncRoot.cpp @@ -248,6 +248,21 @@ HRESULT SyncRoot::UnregisterSyncRoot(const GUID &providerId) } } +HRESULT SyncRoot::UnregisterSyncRoot(const wchar_t *providerIdStr) +{ + try + { + Logger::getInstance().log("Unregistering sync root (string).", LogLevel::INFO); + winrt::StorageProviderSyncRootManager::Unregister(providerIdStr); + return S_OK; + } + catch (...) + { + wprintf(L"Could not unregister the sync root (string), hr %08x\n", static_cast(winrt::to_hresult())); + return E_FAIL; + } +} + HRESULT SyncRoot::ConnectSyncRoot(const wchar_t *syncRootPath, InputSyncCallbacks syncCallbacks, napi_env env, CF_CONNECTION_KEY *connectionKey) { try diff --git a/native-src/virtual_drive/Wrappers.cpp b/native-src/virtual_drive/Wrappers.cpp index 01b0eed9..5ca8c63e 100644 --- a/native-src/virtual_drive/Wrappers.cpp +++ b/native-src/virtual_drive/Wrappers.cpp @@ -127,6 +127,13 @@ napi_value CreatePlaceholderFile(napi_env env, napi_callback_info args) return resultObj; } +/** + * v2.5.7 Carlos Gonzalez + * Added backward compatibility for the default virtual drive identifier "syncRootID". + * If the provided ID is "syncRootID", it will be unregistered without throwing an error, + * maintaining support for previous versions that used it instead of a GUID. + */ + napi_value UnregisterSyncRootWrapper(napi_env env, napi_callback_info args) { size_t argc = 1; @@ -147,15 +154,25 @@ napi_value UnregisterSyncRootWrapper(napi_env env, napi_callback_info args) providerIdStr = new WCHAR[providerIdStrLength + 1]; napi_get_value_string_utf16(env, argv[0], reinterpret_cast(const_cast(providerIdStr)), providerIdStrLength + 1, nullptr); - if (FAILED(CLSIDFromString(providerIdStr, &providerId))) + + HRESULT result; + HRESULT guidResult = CLSIDFromString(providerIdStr, &providerId); + + if (SUCCEEDED(guidResult)) { - napi_throw_error(env, nullptr, "Invalid GUID format"); + result = SyncRoot::UnregisterSyncRoot(providerId); + } + else if (wcscmp(providerIdStr, L"syncRootID") == 0) + { + result = SyncRoot::UnregisterSyncRoot(providerIdStr); + } + else + { + napi_throw_error(env, nullptr, "Invalid provider ID: must be a GUID or 'syncRootID'"); delete[] providerIdStr; return nullptr; } - HRESULT result = SyncRoot::UnregisterSyncRoot(providerId); - delete[] providerIdStr; napi_value napiResult; diff --git a/package.json b/package.json index f9b1284a..e3b149f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/node-win", - "version": "1.0.21", + "version": "1.0.22", "author": "Internxt ", "description": "Drive desktop node addon", "main": "dist/index.js",