Repository navigation
make cfapi registration more resilient - #1213
Merged
Merged
Conversation
TheOneRing
force-pushed
the
work/cfapi_try
branch
from
November 2, 2026 10:42
0a95df3 to
3942798
Compare
TheOneRing
requested review from
fracturehill
and
a balanced review from Copilot
November 2, 2026 10:47
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Case-sensitive path comparison can incorrectly reject the same Windows folder, while replacing a registration after an account UUID change bypasses downgrade protection.
2 open issues
What changed in this PR
This PR improves Windows CFAPI sync-root registration resilience and makes initialization failures visible to callers.
Changes:
- Validates existing registrations, replaces stale registrations, and adds downgrade protection.
- Retries registration on intermittent
ERROR_NOT_FOUNDfailures. - Emits connection errors and removes the assertion on registration failure.
| File | Description |
|---|---|
src/plugins/vfs/cfapi/vfs_cfapi.cpp |
Reports connection failures through the error signal and updates connection-key assignment. |
src/plugins/vfs/cfapi/cfapiwrapper.cpp |
Adds existing-registration validation, stale-registration replacement, and bounded retries. |
Review effort: Balanced
Comment on lines
+384
to
+387
| // append an empty segment to normalise trailing separators | ||
| const auto oldRoot = (OCC::FileSystem::Path(oldPath).get() / L"").lexically_normal(); | ||
| const auto root = (params.root().get() / L"").lexically_normal(); | ||
| if (oldRoot != root) { |
Comment on lines
+391
to
+400
| // a left over registration of ours for the same folder, the id changed for example because the account was set up again | ||
| qCWarning(lcCfApiWrapper) << u"Removing outdated sync root registration" << oldId << u"replacing it with" << id; | ||
| winrt::StorageProviderSyncRootManager::Unregister(previousInfo.Id()); | ||
| return {}; | ||
| } | ||
|
|
||
| if (QVersionNumber::fromString(oldVersion) > params.providerVersion) { | ||
| return u"Downgrading the folder %1 from %2 to %3 is not supported"_s.arg(params.filesystemPath(), oldVersion, params.providerVersion.toString()); | ||
| } | ||
| return {}; |
fracturehill
reviewed
Nov 3, 2026
|
|
||
| winrt::Streams::DataWriter streamWriter; | ||
| streamWriter.WriteString(params.account->uuid().toString().toStdWString()); | ||
| info.Context(streamWriter.DetachBuffer()); |
Contributor
There was a problem hiding this comment.
I feel like this StreamWriter may be the cause of the intermittent failures below; the async write isn't done by the first call to Register(), but is ready on the second. Maybe try replacing this block with something like
auto wstring = params.account->uuid().toString().toStdWString();
auto buffer = winrt::Streams::Buffer(wstring.size() * sizeof(std::wstring::size_t));
uint8_t* rawData = buffer.data();
...and then write to the rawData ponter
fracturehill
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.