-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix macOS File Provider Synchronization Drops #10734
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9102775
fix(file-provider): mark locally created directories as visited
juliusvaart 59f7252
test(file-provider): add remote-change propagation regression tests
juliusvaart 1976736
fix(file-provider): keep trashed rows out of the working-set scan
juliusvaart 746268a
fix(file-provider): do not log expected noSuchItem when pinning a sub…
juliusvaart de8d9b7
fix(file-provider): wait for account setup instead of failing early r…
juliusvaart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
90 changes: 90 additions & 0 deletions
90
...cOSX/NextcloudFileProviderKit/Tests/NextcloudFileProviderKitTests/AwaitAccountTests.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
|
||
| import FileProvider | ||
| import Foundation | ||
| @testable import NextcloudFileProviderKit | ||
| import Testing | ||
|
|
||
| /// | ||
| /// Coverage for `awaitAccount`, which waits for account setup instead of failing the requests the | ||
| /// framework makes before the main app has handed the account over. | ||
| /// | ||
| struct AwaitAccountTests { | ||
| private static let account = Account( | ||
| user: "testUser", id: "testUserId", serverUrl: "https://mock.nc.com", password: "abcd" | ||
| ) | ||
|
|
||
| private func makeExtension() -> FileProviderExtension { | ||
| let domain = NSFileProviderDomain( | ||
| identifier: NSFileProviderDomainIdentifier("test-domain-await-account"), | ||
| displayName: "Test" | ||
| ) | ||
| return FileProviderExtension(domain: domain) | ||
| } | ||
|
|
||
| /// | ||
| /// An account already in place is returned without waiting at all. | ||
| /// | ||
| @Test func returnsImmediatelyWhenAccountIsAlreadySetUp() async throws { | ||
| let ext = makeExtension() | ||
| ext.ncAccount = Self.account | ||
|
|
||
| let account = try await ext.awaitAccount(timeoutNanoseconds: 0) | ||
|
|
||
| #expect(account == Self.account) | ||
| } | ||
|
|
||
| /// | ||
| /// The waiting case: a request arrives first, the account lands while it is parked, and the | ||
| /// request proceeds instead of failing. | ||
| /// | ||
| @Test func waitsForAnAccountThatArrivesLater() async throws { | ||
| let ext = makeExtension() | ||
|
|
||
| async let awaited = ext.awaitAccount(timeoutNanoseconds: 10_000_000_000) | ||
|
|
||
| try await Task.sleep(for: .milliseconds(200)) | ||
| ext.ncAccount = Self.account | ||
| ext.signalAccountReady() | ||
|
|
||
| let account = try await awaited | ||
|
|
||
| #expect(account == Self.account, "A request parked before setup must proceed once the account lands.") | ||
| } | ||
|
|
||
| /// | ||
| /// A domain that never gets an account fails after the timeout rather than hanging forever. | ||
| /// | ||
| @Test func givesUpAfterTheTimeoutWhenNoAccountArrives() async { | ||
| let ext = makeExtension() | ||
| let timeout = Duration.milliseconds(300) | ||
|
|
||
| let started = ContinuousClock().now | ||
|
|
||
| await #expect(throws: NSFileProviderError(.notAuthenticated)) { | ||
| try await ext.awaitAccount(timeoutNanoseconds: 300_000_000) | ||
| } | ||
|
|
||
| #expect(ContinuousClock().now - started >= timeout) | ||
| } | ||
|
|
||
| /// | ||
| /// Several parked requests are all released by the single setup completion. | ||
| /// | ||
| @Test func releasesEveryParkedWaiter() async throws { | ||
| let ext = makeExtension() | ||
|
|
||
| async let first = ext.awaitAccount(timeoutNanoseconds: 10_000_000_000) | ||
| async let second = ext.awaitAccount(timeoutNanoseconds: 10_000_000_000) | ||
| async let third = ext.awaitAccount(timeoutNanoseconds: 10_000_000_000) | ||
|
|
||
| try await Task.sleep(for: .milliseconds(200)) | ||
| ext.ncAccount = Self.account | ||
| ext.signalAccountReady() | ||
|
|
||
| let results = try await [first, second, third] | ||
|
|
||
| #expect(results == [Self.account, Self.account, Self.account]) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.