Skip to content

Check for trash in server capabilities before attempting trash-related operations#74

Merged
claucambra merged 9 commits into
mainfrom
bugfix/trash-capabilities
May 12, 2025
Merged

Check for trash in server capabilities before attempting trash-related operations#74
claucambra merged 9 commits into
mainfrom
bugfix/trash-capabilities

Conversation

@claucambra
Copy link
Copy Markdown
Contributor

No description provided.

claucambra added 8 commits May 9, 2025 14:01
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>
@claucambra claucambra added this to the 2.1 milestone May 9, 2025
@claucambra claucambra requested a review from Copilot May 9, 2025 07:23
@claucambra claucambra self-assigned this May 9, 2025
@claucambra claucambra added the bug Something isn't working label May 9, 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 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,##))

Comment thread Sources/NextcloudFileProviderKit/Item/Item.swift
…h error

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra claucambra force-pushed the bugfix/trash-capabilities branch from 751a312 to 17dcecf Compare May 12, 2025 04:04
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2025

Codecov Report

Attention: Patch coverage is 77.32558% with 39 lines in your changes missing coverage. Please review.

Project coverage is 81.20%. Comparing base (52e92f5) to head (17dcecf).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...erKit/Interface/NextcloudKit+RemoteInterface.swift 0.00% 16 Missing ⚠️
...tcloudFileProviderKit/Enumeration/Enumerator.swift 65.00% 14 Missing ⚠️
Sources/NextcloudFileProviderKit/Item/Item.swift 33.33% 6 Missing ⚠️
...extcloudFileProviderKitTests/EnumeratorTests.swift 95.45% 2 Missing ⚠️
Tests/Interface/MockRemoteInterface.swift 91.66% 1 Missing ⚠️
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.
📢 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.

@claucambra claucambra merged commit f08095f into main May 12, 2025
2 of 3 checks passed
@claucambra claucambra deleted the bugfix/trash-capabilities branch May 12, 2025 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants