Skip to content

make cfapi registration more resilient - #1213

Merged
TheOneRing merged 1 commit into
mainfrom
work/cfapi_try
Nov 3, 2026
Merged

TheOneRing merged 1 commit into
mainfrom
work/cfapi_try

Conversation

@TheOneRing

Copy link
Copy Markdown
Contributor

No description provided.

@TheOneRing TheOneRing changed the title make cfapi registration more resilitan make cfapi registration more resiliant Nov 2, 2026
@TheOneRing
TheOneRing requested review from fracturehill and a balanced review from Copilot November 2, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_FOUND failures.
  • 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 {};

winrt::Streams::DataWriter streamWriter;
streamWriter.WriteString(params.account->uuid().toString().toStdWString());
info.Context(streamWriter.DetachBuffer());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@TheOneRing
TheOneRing merged commit 5a24f4e into main Nov 3, 2026
@TheOneRing
TheOneRing deleted the work/cfapi_try branch November 3, 2026 14:24
@openclouders openclouders mentioned this pull request Nov 13, 2026
1 task
@TheOneRing TheOneRing changed the title make cfapi registration more resiliant make cfapi registration more resilient Nov 23, 2026
@saw-jan saw-jan mentioned this pull request Nov 25, 2026
9 of 22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants