Skip to content

Add ability to mark items to always keep them downloaded#75

Merged
claucambra merged 14 commits into
mainfrom
bugfix/keep-offline
May 14, 2025
Merged

Add ability to mark items to always keep them downloaded#75
claucambra merged 14 commits into
mainfrom
bugfix/keep-offline

Conversation

@claucambra
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra claucambra added this to the 2.1 milestone May 13, 2025
@claucambra claucambra requested a review from Copilot May 13, 2025 06:33
@claucambra claucambra self-assigned this May 13, 2025
@claucambra claucambra added the enhancement New feature or request label May 13, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to mark items to keep them offline by introducing a new Boolean property ("keepOffline") across metadata types, updating the item’s content policy, and adding corresponding database and UI handling logic.

  • Added the "keepOffline" flag to Realm, Sendable, and protocol definitions.
  • Implemented tests, database manager extensions, and Item extensions facilitating the toggling and setting of the offline flag.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Tests/NextcloudFileProviderKitTests/FilesDatabaseManagerTests.swift Adds a test to verify keepOffline behavior via the database manager.
Sources/NextcloudFileProviderKit/Metadata/SendableItemMetadata.swift Introduces the keepOffline property and propagates it in initializers.
Sources/NextcloudFileProviderKit/Metadata/RealmItemMetadata.swift Adds a persisted keepOffline property to the Realm metadata object.
Sources/NextcloudFileProviderKit/Metadata/ItemMetadata.swift Updates the protocol to include the keepOffline property.
Sources/NextcloudFileProviderKit/Item/Item.swift Updates contentPolicy and introduces a computed keepOffline property based on metadata.
Sources/NextcloudFileProviderKit/Item/Item+KeepOffline.swift Provides functions to toggle and set the keepOffline flag on items with proper file provider manager handling.
Sources/NextcloudFileProviderKit/Database/FilesDatabaseManager.swift Adds errorCode definitions and an error domain for offline operations.
Sources/NextcloudFileProviderKit/Database/FilesDatabaseManager+KeepOffline.swift Implements the database update logic for the keepOffline flag with detailed logging and error handling.
Comments suppressed due to low confidence (2)

Sources/NextcloudFileProviderKit/Database/FilesDatabaseManager+KeepOffline.swift:28

  • Consider adding tests to verify that this error branch is executed when the provided metadata is not found in the database.
guard let result = itemMetadatas.where({ $0.ocId == metadata.ocId }).first else {

Sources/NextcloudFileProviderKit/Database/FilesDatabaseManager+KeepOffline.swift:15

  • [nitpick] Consider refining the formatting of the multiline error message for unsupported system versions to improve its clarity and consistency.
guard #available(macOS 13.0, iOS 16.0, visionOS 1.0) else {

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2025

Codecov Report

Attention: Patch coverage is 73.77778% with 59 lines in your changes missing coverage. Please review.

Project coverage is 81.07%. Comparing base (f08095f) to head (b562ee2).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...loudFileProviderKit/Item/Item+KeepDownloaded.swift 0.00% 33 Missing ⚠️
...Database/FilesDatabaseManager+KeepDownloaded.swift 48.78% 21 Missing ⚠️
Sources/NextcloudFileProviderKit/Item/Item.swift 66.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
- Coverage   81.20%   81.07%   -0.13%     
==========================================
  Files          60       62       +2     
  Lines       13293    13507     +214     
==========================================
+ Hits        10794    10951     +157     
- Misses       2499     2556      +57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…if keepOffline is true

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra claucambra changed the title Add ability to mark items to keep them offline Add ability to mark items to always keep them downloaded May 14, 2025
@claucambra claucambra merged commit 8b4f960 into main May 14, 2025
1 of 3 checks passed
@claucambra claucambra deleted the bugfix/keep-offline branch May 14, 2025 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants