-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor unregister sync root #191
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
Changes from all commits
21bd1ad
819a1f1
cc1b678
444a2d5
b5eff5e
fe31746
32c5ea9
75681d6
205f2be
9648c94
46ee84c
313dfbf
ff28084
d1a7164
70d004e
69ce991
1020526
e94646e
0601df9
73a1c9e
ae38d77
f7b6a44
41028a0
38a0e29
4832626
d947054
39f1f5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #pragma once | ||
|
|
||
| #include <node_api.h> | ||
|
|
||
| napi_value unregister_sync_root_wrapper(napi_env env, napi_callback_info args); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,12 +15,6 @@ std::vector<SyncRoots> get_registered_sync_roots() { | |
| sr.path = info.Path().Path(); | ||
| sr.displayName = info.DisplayNameResource(); | ||
| sr.version = info.Version(); | ||
|
|
||
| auto contextBuffer = info.Context(); | ||
| if (contextBuffer) { | ||
| sr.context = winrt::CryptographicBuffer::ConvertBinaryToString(winrt::BinaryStringEncoding::Utf8, contextBuffer).c_str(); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer need the context of the cloud provider since now we are filtering by the displayName and path. |
||
|
|
||
| syncRootList.push_back(sr); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,12 +30,5 @@ void register_sync_root(const wchar_t *syncRootPath, const wchar_t *providerName | |
| winrt::Uri uri(L"https://drive.internxt.com/app/trash"); | ||
| info.RecycleBinUri(uri); | ||
|
|
||
| std::wstring syncRootIdentity(syncRootPath); | ||
| syncRootIdentity.append(L"#inxt#"); | ||
| syncRootIdentity.append(providerName); | ||
|
|
||
| winrt::IBuffer contextBuffer = winrt::CryptographicBuffer::ConvertStringToBinary(syncRootIdentity, winrt::BinaryStringEncoding::Utf8); | ||
| info.Context(contextBuffer); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said, we were adding the context when registering the cloud provider to filter later, however now we filter using the displayName and path. |
||
|
|
||
| winrt::StorageProviderSyncRootManager::Register(info); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #include <windows.h> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the new unregister. Basically now we don't care if it's an uuid, the "syncRoot" text or whatever. We assume that was javascript sends here is a existing sync root, which it should. |
||
| #include <node_api.h> | ||
| #include <string> | ||
| #include "stdafx.h" | ||
|
|
||
| napi_value unregister_sync_root_wrapper(napi_env env, napi_callback_info args) { | ||
| size_t argc = 1; | ||
| napi_value argv[1]; | ||
| napi_get_cb_info(env, args, &argc, argv, nullptr, nullptr); | ||
|
|
||
| size_t providerIdLength; | ||
| napi_get_value_string_utf16(env, argv[0], nullptr, 0, &providerIdLength); | ||
| std::wstring providerId(providerIdLength, L'\0'); | ||
| napi_get_value_string_utf16(env, argv[0], reinterpret_cast<char16_t*>(&providerId[0]), providerIdLength + 1, nullptr); | ||
|
|
||
| winrt::StorageProviderSyncRootManager::Unregister(providerId); | ||
|
|
||
| return nullptr; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve it to handle windows cloud api errors so we can print correctly the errors.