-
Notifications
You must be signed in to change notification settings - Fork 1
Improve connect and disconnect sync root #206
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
Improve connect and disconnect sync root #206
Conversation
|
|
|
||
| CF_CONNECTION_KEY connectionKey; | ||
| HRESULT hr = SyncRoot::ConnectSyncRoot(syncRootPath.c_str(), callbacks, env, &connectionKey); | ||
| SyncRoot::ConnectSyncRoot(syncRootPath.c_str(), callbacks, env); |
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.
Why is the possible error that this function may return no longer being handled?
| auto [syncRootPath] = napi_extract_args<std::wstring>(env, info); | ||
|
|
||
| HRESULT result = SyncRoot::DisconnectSyncRoot(syncRootPath.c_str()); | ||
| SyncRoot::DisconnectSyncRoot(syncRootPath.c_str()); |
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.
Is it not necessary to handle the error here?
| HRESULT hr = CfDisconnectSyncRoot(it->second); | ||
| if (SUCCEEDED(hr)) | ||
| { | ||
| connectionMap.erase(it); | ||
| } | ||
| return hr; | ||
|
|
||
| winrt::check_hresult(hr); |
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.
We need the variable hr?, why not do it as in previous revisions?
winrt::check_hresult(CfDisconnectSyncRoot(it->second));
| HRESULT hr = CfConnectSyncRoot( | ||
| syncRootPath, | ||
| callbackTable, | ||
| nullptr, | ||
| CF_CONNECT_FLAG_REQUIRE_PROCESS_INFO | CF_CONNECT_FLAG_REQUIRE_FULL_FILE_PATH, | ||
| connectionKey); | ||
|
|
||
| wprintf(L"Connection key: %llu\n", connectionKey->Internal); | ||
| &connectionKey); | ||
|
|
||
| if (SUCCEEDED(hr)) | ||
| { | ||
| connectionMap[syncRootPath] = *connectionKey; | ||
| } | ||
| winrt::check_hresult(hr); |
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.
We need the variable hr?, why not do it as in previous revisions?
winrt::check_hresult(CfConnectSyncRoot(
syncRootPath,
callbackTable,
nullptr,
CF_CONNECT_FLAG_REQUIRE_PROCESS_INFO | CF_CONNECT_FLAG_REQUIRE_FULL_FILE_PATH,
&connectionKey));
| napi_throw_error(env, nullptr, "Failed to define properties"); | ||
| return nullptr; | ||
| } | ||
| napi_define_properties(env, exports, property_count, properties); |
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.
Why is it no longer necessary to take this error into account?


What
dehydrate_fileandhydrate_filewith our custom file handlerPlaceholders::OpenFileHandle.connect_sync_rootanddisconnect_sync_rooterror handling to throw an error usingwinrt::check_hresultinstead of returning an error.handleForPathwith our custom file handlerPlaceholders::OpenFileHandle.