You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: shell_integration/MacOSX/NextcloudFileProviderKit/Sources/NextcloudFileProviderKit/Database/FilesDatabaseManager.swift
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -447,6 +447,52 @@ public final class FilesDatabaseManager: Sendable {
447
447
}
448
448
}
449
449
450
+
///
451
+
/// Add or replace `metadata` while carrying over local-only fields the
452
+
/// server payload cannot know about: ``keepDownloaded``, ``downloaded``,
453
+
/// ``visitedDirectory``, and ``lockToken``.
454
+
///
455
+
/// Mirrors the preservation set applied by
456
+
/// ``processItemMetadatasToUpdate`` for non-paginated reads. Use this from
457
+
/// any code path that ingests fresh PROPFIND results (e.g. paginated
458
+
/// enumeration); plain ``addItemMetadata(_:)`` would otherwise overwrite
459
+
/// these fields back to their defaults via Realm's `update: .all`,
460
+
/// silently undoing user-visible state such as "Always keep downloaded"
461
+
/// (#9923).
462
+
///
463
+
/// Returns the merged metadata that was persisted. Callers that report
464
+
/// items back to the file-provider framework MUST forward the returned
465
+
/// value rather than the input — otherwise the framework receives the
466
+
/// pre-merge defaults and renders the item as if the local-only state
467
+
/// (e.g. pinned-via-keep-downloaded) had been cleared.
468
+
///
469
+
/// - Parameters:
470
+
/// - metadata: The freshly-built metadata to persist.
471
+
/// - preserveVisitedDirectory: When `false`, do not carry over
472
+
/// ``visitedDirectory`` from the existing row. Callers that have just
473
+
/// visited the directory in the current request should pass `false`
474
+
/// and pre-set `metadata.visitedDirectory = true`, so the visit is
475
+
/// recorded rather than overwritten by a stale `false` from the DB.
Copy file name to clipboardExpand all lines: shell_integration/MacOSX/NextcloudFileProviderKit/Sources/NextcloudFileProviderKit/Enumeration/Enumerator+SyncEngine.swift
Copy file name to clipboardExpand all lines: shell_integration/MacOSX/NextcloudFileProviderKit/Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift
+139Lines changed: 139 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -472,6 +472,145 @@ final class EnumeratorTests: NextcloudFileProviderKitTestCase {
472
472
)
473
473
}
474
474
475
+
///
476
+
/// Children persisted by a page-0 paginated read must keep their existing
477
+
/// ``keepDownloaded`` flag. Before the fix for #9923 the bulk write at the
478
+
/// end of ``Enumerator.handlePagedReadResults`` used ``addItemMetadata``
479
+
/// which replaces the entire row, silently clearing flags set by a prior
480
+
/// "Always keep downloaded" enable.
481
+
///
482
+
/// The metadatas returned to the enumeration observer must also reflect
483
+
/// the preserved state: the framework builds `Item.contentPolicy` from
484
+
/// `metadata.keepDownloaded` on whatever metadata we hand it, so reporting
485
+
/// the pre-merge fresh-from-server metadata would leave the OS view of
486
+
/// pinned descendants stuck on `.inherited` even though the database row
487
+
/// is correct. (Symptom observed in #9923 for `/Documents/Documenter`.)
"Page-0 child \(ocId) reported back to the enumeration observer must also reflect the preserved keepDownloaded — the framework builds contentPolicy from this value."
Copy file name to clipboardExpand all lines: shell_integration/MacOSX/NextcloudFileProviderKit/Tests/NextcloudFileProviderKitTests/KeepDownloadedRecursiveTests.swift
+86Lines changed: 86 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -455,4 +455,90 @@ final class KeepDownloadedRecursiveTests: NextcloudFileProviderKitTestCase {
455
455
"A sibling outside the pinned folder must not inherit keepDownloaded."
456
456
)
457
457
}
458
+
459
+
///
460
+
/// End-to-end regression for #9923: a paginated read that lands on
461
+
/// already-pinned descendants must not silently clear their flag. Before
462
+
/// the fix, the bulk write at the end of
463
+
/// ``Enumerator.handlePagedReadResults`` used ``addItemMetadata`` which
464
+
/// replaces rows wholesale via Realm's `update: .all`, dropping every
465
+
/// local-only field — including ``keepDownloaded``. The user's pin walk
466
+
/// runs without pagination, but the OS-driven `enumerateItems` that
467
+
/// follows uses pagination, so a recently-pinned subtree was reliably
0 commit comments