Check for trash in server capabilities before attempting trash-related operations#74
Merged
Conversation
It's not great, but we are likely to be in a situation where capabilities are already fetched and cached Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…ting trashing during modify Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…o enumerate trash Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…ities Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
… capabilities Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
…apabilities Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances trash-related operations by checking the server’s capabilities before proceeding with trash actions. Key changes include:
- Adding tests that simulate the absence of the "undelete" capability and assert failure of trash operations.
- Updating the Item capability logic to only include trashing when the server supports undelete.
- Introducing synchronous wrappers for fetching capabilities for compatibility.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/NextcloudFileProviderKitTests/ItemPropertyTests/ItemPropertyTests.swift | Introduces a new test to verify that trashing is disabled when the undelete capability is removed. |
| Tests/NextcloudFileProviderKitTests/ItemModifyTests.swift | Adds a test case that ensures moving an item to trash fails when the server does not support undelete. |
| Tests/NextcloudFileProviderKitTests/EnumeratorTests.swift | Adds test cases for enumerating trash items and changes, ensuring proper error handling. |
| Tests/Interface/MockRemoteInterface.swift | Updates the currentCapabilities API with default parameter values and provides a synchronous variant. |
| Sources/NextcloudFileProviderKit/Item/Item.swift | Updates the capability logic to conditionally insert the trashing flag based on server capabilities. |
| Sources/NextcloudFileProviderKit/Item/Item+Modify.swift | Checks server capabilities before performing trash operations and handles errors accordingly. |
| Sources/NextcloudFileProviderKit/Interface/RemoteInterface.swift | Adds a synchronous capabilities function to support legacy usage. |
| Sources/NextcloudFileProviderKit/Interface/NextcloudKit+RemoteInterface.swift | Provides a synchronous wrapper with a semaphore in the remote interface extension. |
| Sources/NextcloudFileProviderKit/Enumeration/Enumerator.swift | Enhances trash enumeration by checking capabilities before enumerating trash items or changes. |
Comments suppressed due to low confidence (1)
Tests/NextcloudFileProviderKitTests/ItemPropertyTests/ItemPropertyTests.swift:259
- [nitpick] Consider defining a constant for the undelete capability string used in tests to improve maintainability and reduce repetition in the mock capabilities string manipulation.
XCTAssert(remoteInterface.capabilities.contains(##"undelete": true,##))
…h error Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
751a312 to
17dcecf
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 81.11% 81.20% +0.09%
==========================================
Files 62 60 -2
Lines 13039 13293 +254
==========================================
+ Hits 10576 10794 +218
- Misses 2463 2499 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.