Skip to content

Add macOS on-demand Finder integration and exclusive sync modes - #3

Draft
restot wants to merge 371 commits into
mainfrom
feature/macos-vfs
Draft

restot wants to merge 371 commits into
mainfrom
feature/macos-vfs

Conversation

@restot

@restot restot commented Dec 28, 2025 •

Copy link
Copy Markdown
Owner

macOS now defaults to native FileProvider on-demand locations in Finder when the extension is available. Files download when opened, and Finder provides controls for keeping files downloaded or removing local downloads. General Settings offers traditional folder sync after restart. The two modes are mutually exclusive: domain disconnection completes before traditional sync starts, preserving existing local files and folder configuration.

The cleaned upstream contribution is now open as opencloud-eu/desktop#1128, a draft with four focused commits. Please use that PR for upstream architecture and integration review. This fork PR preserves the development and release history. Independent testing and the remaining fixes continue; upstream review and acceptance are still pending.

Implementation

  • Separate Finder locations for spaces, credentials scoped to each domain, persistent item identities and change history, and conflict-safe writes.
  • Sync status in the tray and Settings, local Finder metadata, scoped cloud search, remote thumbnails, server Trash/restore/permanent deletion, and browser sharing/version actions.
  • Native Finder download and pinning controls. Apple's private iCloud sidebar presentation is outside the public FileProvider API, and Desktop and Documents backup is outside this change.
  • Fixes for Finder socket lifecycle, dependency bundling, extension version metadata, and the crash helper's path validation and loopback binding.
  • Latest merged upstream code through b6bdb1f1f, bringing the app to 4.0.1. Account deletion preserves inactive folder settings without initializing another VFS provider.

Testing and release

The latest test build is v0.4. Its Apple Silicon DMG is Developer ID signed and notarized by Apple, with a stapled ticket. The app reports version 4.0.1; v0.4 is the fork's release number. The package uses Qt 6.9.2. Its on-demand FileProvider extension requires macOS 26 or later, including cloud search; earlier wording overstated support for older macOS versions.

Validation on the development Mac:

  • Desktop client and both universal Finder extensions build successfully.
  • All 45 selected CTest suites pass. The interactive credential-manager test was excluded; Keychain behavior was exercised separately in the signed Finder tests.
  • The signed isolated Finder exercise passes XPC authorization, Keychain isolation/recovery, hydration, upload, rename, package contents, Trash/restore/permanent deletion, offline access, eviction, revocation, and disconnect/reconnect.
  • Both General Settings mode switches were manually verified with restart, and the saved login survived without another Keychain prompt. Live Personal and virtual Shares locations recorded successful synchronization.
  • Gatekeeper, disk-image, translation XML, GUI Python/Gherkin syntax, and OpenSpec checks pass. Clean-machine installation has not been certified.

Independent testing is welcome, especially changes from another device, creating and moving folders, offline edits, multiple accounts, and switching sync modes. Please use a separate test account and disposable files. Reports should include macOS/server versions, reproduction steps, and sanitized logs. Swift/C++ review is welcome too. I understand that not everyone can participate in beta testing, and that's fine.

Remaining work and limits

  • #8: Settings reports Finder integration as disabled: make the indicator aware of the active provider and refresh its state.
  • #10: Cross-device folder synchronization: confirm the reporter's exact iOS-created folder and Finder-created empty-folder workflows on the current release.
  • A failed new upload discarded before receiving a server ID can leave an error visible until recovery or status reset, tracked locally as bd-1c8.
  • Finder metadata remains local to this Mac. Existing traditional-sync files remain on disk when switching modes; the client does not automatically delete or migrate them.

See Finder behavior and limits, review evidence, and test commands.

Preparing for upstream

Cc @dragotin @TheOneRing. I would appreciate guidance on the architecture, cross-platform integration requirements, and how to split this work into manageable upstream PRs. That advice would help me prepare a contribution that fits the official client.

Special thanks to @3zero2 for early testing and detailed issue reports.

Related upstream discussions: Roadmap #52 and desktop #166. Those feature requests remain open while upstream integration is pending.

@restot

restot commented Feb 17, 2026 •

Copy link
Copy Markdown
Owner Author

Updated 2026-02-17 after codebase validation — 1 finding removed (invalid), 2 downgraded.

Completeness Gaps

Spec vs implementation mismatches:

1. No tests for new C++ code [MISSING]
~1,100 lines of new C++ in src/gui/macOS/fileprovider*.h with zero test coverage in test/.
Fix: Add unit tests for the new FileProvider C++ classes.

2. getPropagator() added "for the test" but no test exists [PARTIAL]
src/libsync/syncengine.h line 128 adds a public accessor with a // for the test comment, but nothing in test/ calls it. The unique_ptr-to-QSharedPointer ownership change was made solely for this unused method.
Fix: Either add the test that needs this accessor, or revert the ownership change.

3. getfilejob.cpp changes are unrelated to FileProvider VFS [DRIFT]
src/libsync/networkjobs/getfilejob.cpp removes _device->close() and introduces a typo. These are behavioral changes to the core sync engine that don't belong in this PR.
Fix: Split into a separate PR.

4. hydrationdevice.cpp changes target Windows cfapi, not macOS FileProvider [DRIFT]
src/plugins/vfs/cfapi/hydrationdevice.cpp reduces buffer size from 4 MiB to 40 KiB in the Windows Cloud Files API plugin. Nothing to do with macOS.
Fix: Split into a separate PR.

5. propagateupload.h changes unrelated to FileProvider VFS [DRIFT]
src/libsync/propagateupload.h adds an empty Q_SIGNALS: section and a logging category declaration with no FileProvider connection.
Fix: Split into a separate PR or remove.

6. utility_unix.cpp refactoring unrelated to FileProvider VFS [DRIFT]
src/libsync/common/utility_unix.cpp refactors Linux desktop entry formatting. Unrelated to macOS.
Fix: Split into a separate PR.


Findings

1. Typo regression: "badnwidth" instead of "bandwidth"
src/libsync/networkjobs/getfilejob.cpp line 225 -- the diff changes "Out of bandwidth quota" to "Out of badnwidth quota".
Fix: Fix the typo.

2. Removing _device->close() — confirm intent (downgraded to informational)
src/libsync/networkjobs/getfilejob.cpp -- the _device->close() call and its comment are removed from the normal finished() path. The header comment says "DOES NOT take ownership of the device" (line 29), so the caller is responsible for the device lifecycle. This may be by-design, but the removal of the explanatory comment suggests it was accidental.
Fix: Confirm this is intentional, or restore the call.

3. Removing the Http2 disable guard (removed — invalid)
The HTTP/2 disable guard exists globally in accessmanager.cpp (QNetworkRequest::Http2AllowedAttribute), not per-job. This finding was incorrect.

4. _propagator ownership weakened for unused accessor
src/libsync/syncengine.h lines 128, 214 -- unique_ptr changed to QSharedPointer and getPropagator() added with a // for the test comment, but no test uses it.
Fix: Revert to unique_ptr or add the test.

5. Empty Q_SIGNALS: section
src/libsync/propagateupload.h line 62 -- dead code.
Fix: Remove.

6. Raw milliseconds instead of chrono literals
src/gui/macOS/fileprovider_mac.mm line 96, src/gui/macOS/fileproviderxpc_mac.mm line 53 -- QTimer::singleShot(1000, ...) and setInterval(4 * 60 * 1000) should use std::chrono literals per project convention.
Fix: Use 1s, 4min, etc.

7. dispatch_group_wait(DISPATCH_TIME_FOREVER) blocks calling thread (4 sites)
src/gui/macOS/fileproviderdomainmanager_mac.mm lines 132, 321, 335 and src/gui/macOS/fileproviderxpc_mac.mm line 301 -- these will hang the thread indefinitely if the NSFileProviderManager completion handler never fires.
Fix: Use a timeout or dispatch to a background queue with async completion.

8. accessToken() exposed publicly (downgraded to low)
src/libsync/creds/httpcredentials.h line 63 -- QString accessToken() const { return _accessToken; } is public. HttpCredentialsAccessManager is already a friend class (line 46), so this may be intentionally public for other callers. Low priority — consider restricting if no external consumer exists.

9. Mixed string literal styles
src/libsync/common/utility_unix.cpp lines 112-122 -- mixes QLatin1String(...) with u"..." in the same function.
Fix: Pick one style and be consistent.

10. HydrationDevice buffer size reduced ~100x without explanation
src/plugins/vfs/cfapi/hydrationdevice.cpp line 18 -- BufferSize changed from 4_MiB to ChunkSize * 10 (40 KiB). This means the flush threshold drops from 3.6 MiB to 4 KiB, resulting in ~900x more CF_OPERATION_TYPE_TRANSFER_DATA calls.
Fix: Add a comment explaining the rationale, or revert if this was unintentional.

11. sqlite3_column_text will crash on NULL columns
shell_integration/.../Database/ItemDatabase.swift lines 383-411 -- 10 occurrences of String(cString: sqlite3_column_text(stmt, col)) with no nil guard. sqlite3_column_text returns NULL for SQL NULL values, and passing NULL to String(cString:) is undefined behavior. (Note: the code correctly guards the nullable statusError column at lines 418-423, but not the NOT NULL columns.)
Fix: Guard with nil check or use a helper:

func columnString(_ stmt: OpaquePointer?, _ col: Int32) -> String {
    guard let cStr = sqlite3_column_text(stmt, col) else { return "" }
    return String(cString: cStr)
}

12. deleteDirectoryAndSubdirectories is O(n^2) and not atomic
shell_integration/.../Database/ItemDatabase.swift lines 255-275 -- BFS traversal with individual SELECT and DELETE queries per node, no transaction wrapping.
Fix: Use a recursive CTE or LIKE query in a single transaction.

13. Polling loop for authentication is CPU-wasteful
shell_integration/.../FileProviderEnumerator.swift lines 98-115 -- waitForAuthentication uses a polling loop with Task.sleep at 500ms intervals. Same pattern duplicated in FileProviderExtension.swift at lines 469-474 and 547-551. Also, the Int(elapsed) % 5 == 0 logging condition fires twice per 5-second boundary due to the 0.5s interval.
Fix: Use a notification or async event instead of polling. Fix the modulus condition.

14. Base64url decoding duplicated 3 times
shell_integration/.../FileProviderEnumerator.swift lines 150, 251 and shell_integration/.../FileProviderExtension.swift line 278 -- the .replacingOccurrences(of: "_", with: "/") base64url decode logic is copy-pasted verbatim in three places.
Fix: Extract to a shared String extension or utility function.

15. Download + DB update block duplicated in fetchContents
shell_integration/.../FileProviderExtension.swift lines 414-456 and 479-507 -- the download-update-DB-signal sequence (~25 lines) is duplicated between the happy path and the retry path, differing only in variable names.
Fix: Extract the common sequence into a helper method.

16. HTTP 403 mapped to insufficientQuota instead of a permission error
shell_integration/.../FileProviderExtension.swift lines 524-525, 809-810 -- permissionDenied is mapped to NSFileProviderError(.insufficientQuota). That's semantically wrong — users will see "not enough storage" when the problem is a permission issue.
Fix: Map to an appropriate permission-related error code.

17. WebDAVError-to-NSFileProviderError mapping repeated 3 times with divergent coverage
shell_integration/.../FileProviderExtension.swift lines 519, 634, 803 -- three switch webdavError blocks that each handle a slightly different set of cases (e.g. createItem at line 634 is missing the permissionDenied case). This divergence is a bug risk.
Fix: Extract a single shared mapping function.

18. 49 NSLog calls alongside Logger -- remove debug scaffolding
Multiple files in FileProviderExt/: FileProviderExtension.swift (22), LocalSocketClient.m (16), ClientCommunicationService.swift (4), FileProviderEnumerator.swift (4), WebDAVXMLParser.swift (2), WebDAVClient.swift (1). These duplicate the existing Logger infrastructure and some log every enumerated item individually.
Fix: Remove the NSLog calls before merge.

19. Auth type guessed from password string heuristic
shell_integration/.../FileProviderExtension.swift line 892 -- password.count > 100 || password.hasPrefix("ey") is a fragile way to detect OAuth tokens when the main app already knows the credential type.
Fix: Pass the auth type explicitly from the main app via XPC.

20. ARC not enabled for new Obj-C++ files
src/gui/CMakeLists.txt -- ARC (-fobjc-arc) is only enabled for socketapisocket_mac.mm. The new FileProvider .mm files don't have ARC, requiring manual retain/release.
Fix: Enable ARC for the new .mm files, or document why manual memory management is intentional.


Out of Scope

Pre-existing issues, consider follow-up:

1. Singleton without Q_DISABLE_COPY - src/gui/macOS/fileprovider.h
FileProvider is a singleton with a private constructor but no Q_DISABLE_COPY(FileProvider) macro to prevent copy/move. (Minor — QObject already deletes copy ctor.)

2. OAuth token stored in plaintext UserDefaults - shell_integration/.../FileProviderExtension.swift
OAuth bearer token is stored in UserDefaults (a plist file) instead of Keychain. This is a security concern.

3. Thread-unsafe shared static state - shell_integration/.../FileProviderExtension.swift
_sharedWebDAVClient and _sharedIsAuthenticated are plain static var properties (lines 33-64) accessed from multiple extension instances without synchronization. Needs actor isolation or a serial queue.


Request Changes

This PR introduces substantial macOS FileProvider functionality, but it needs work before merge:

  • 4 unrelated changes to the core sync engine (getfilejob.cpp, hydrationdevice.cpp, propagateupload.h, utility_unix.cpp) should be split into separate PRs.
  • 2 high-severity bugs: a typo regression and 10 sites where sqlite3_column_text will crash on NULL values.
  • 4 blocking dispatch_group_wait(DISPATCH_TIME_FOREVER) calls that can hang the app.
  • Significant code duplication in the Swift extension code (base64 decoding, error mapping, download logic, auth polling) needs cleanup before it becomes tech debt.

I'd recommend splitting out the unrelated changes, fixing the high-severity issues, and doing a dedup pass on the Swift code before re-review.

Review base: bca6e7fb (HEAD of feature/macos-vfs, including unstaged changes)

openclouders and others added 26 commits March 27, 2026 00:13
* test(gui): gui test automation with appium

Signed-off-by: Saw-jan <[email protected]>

* test: pin python modules

Signed-off-by: Saw-jan <[email protected]>

* test: fix sync pattern check

Signed-off-by: Saw-jan <[email protected]>

* fix: replace with print

Signed-off-by: Saw-jan <[email protected]>

* ci: disable squish ci pipeline

Signed-off-by: Saw-jan <[email protected]>

* test: use selector as object

Signed-off-by: Saw-jan <[email protected]>

* test: use app

Signed-off-by: Saw-jan <[email protected]>

* test: fix selector

Signed-off-by: Saw-jan <[email protected]>

---------

Signed-off-by: Saw-jan <[email protected]>
* test: try to delete config dir only if exists

Signed-off-by: Sajan Gurung <[email protected]>

* test: fix config path

Signed-off-by: Sajan Gurung <[email protected]>

* test: check for nul values

Signed-off-by: Sajan Gurung <[email protected]>

* test: enable multiple account test

Signed-off-by: Sajan Gurung <[email protected]>

* test: fix multiple account test

Signed-off-by: Sajan Gurung <[email protected]>

* test: add sure assertion module

Signed-off-by: Sajan Gurung <[email protected]>

* test: use const for config filename

Signed-off-by: Sajan Gurung <[email protected]>

* test: fix python requirement entry

Signed-off-by: Sajan Gurung <[email protected]>

---------

Signed-off-by: Sajan Gurung <[email protected]>
* test: port tst_deleteFilesFolders suite

* test: fix placement of files

* test: use ensure instead of assert
* test(gui): enable manual folder sync scenario

Signed-off-by: Saw-jan <[email protected]>

* test(gui): enable account re-add scenario

Signed-off-by: Saw-jan <[email protected]>

* test(gui): skip manual sync scenario

Signed-off-by: Saw-jan <[email protected]>

* test(gui): check space selection

Signed-off-by: Saw-jan <[email protected]>

* test(gui): remove obsolete step files

Signed-off-by: Saw-jan <[email protected]>

---------

Signed-off-by: Saw-jan <[email protected]>
…ud-eu#878)

* port removeAccountConnection test suite to appium

Signed-off-by: prashant-gurung899 <[email protected]>

* test: fix account selection

Signed-off-by: Saw-jan <[email protected]>

---------

Signed-off-by: prashant-gurung899 <[email protected]>
Signed-off-by: Saw-jan <[email protected]>
Co-authored-by: Saw-jan <[email protected]>
* test(gui): fix and enable spaces scenarios

Signed-off-by: Saw-jan <[email protected]>

* test(gui): fix and enable spaces scenarios

Signed-off-by: Saw-jan <[email protected]>

---------

Signed-off-by: Saw-jan <[email protected]>
* test: port tst_deleteFilesFolders suite

* test: port tst_editFiles

* test: remove resource_types registration from file

* test: fix indentation in feature file

* test: remove resource_types registration from file
* enable more syncing tests in appium

Signed-off-by: prashant-gurung899 <[email protected]>

* enable more syncing tests in appium

Signed-off-by: prashant-gurung899 <[email protected]>

---------

Signed-off-by: prashant-gurung899 <[email protected]>
* test: port tst_loginLogout

* test: fix closing of client

* test: Add reusable close_and_kill_app() for Appium session and process cleanup

* test: remove test.py

* test: use exception handlers in sync helper
TheOneRing and others added 23 commits September 10, 2026 12:05
Add security-events permission to workflow to allow CodeQL Actions
* replace minio image

* replace minio image
* Add GUI test for syncing hidden files

* link issue. skip test
Default to the compatible on-demand FileProvider extension and offer traditional folder sync in Settings. Apply switches on restart, disconnect domains before local sync starts, and preserve inactive folder settings and local files.

Co-Authored-By: Codex <[email protected]>
Isolate domain credentials, preserve version conflicts and durable enumeration changes, distinguish shutdown from account deletion, and acknowledge credential cleanup. Fix Finder socket and menu lifetimes, crash-report path traversal, and lost translations. Add regression suites and record remaining review findings.

Co-Authored-By: Codex <[email protected]>
@restot restot changed the title Feature/macos vfs Add macOS on-demand Finder integration and exclusive sync modes Sep 27, 2026
restot added 4 commits September 26, 2026 21:33
Integrate opencloud-eu/desktop main at b6bdb1f, including version
4.0.1, current CI, translations, and the reorganized GUI test suite.
Preserve macOS FileProvider build settings and align extension versions.

Keep inactive folder settings opaque during account deletion so upstream
VFS preparation cannot activate a second provider. Cover preserved
provider modes and nested settings in the provider-selection regression.

Validation: desktop and both universal extensions build; 45 CTest suites
pass. The interactive credential-manager suite was excluded; signed
Finder/XPC/Keychain and file-operation checks pass separately. Translation
XML, GUI Python/Gherkin syntax, and four OpenSpec changes validate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.