Skip to content

Correctly handle non-recursive delete of non-empty directory#71

Merged
claucambra merged 2 commits into
mainfrom
bugfix/handle-non-recursive-non-empty-dir-del
May 9, 2025
Merged

Correctly handle non-recursive delete of non-empty directory#71
claucambra merged 2 commits into
mainfrom
bugfix/handle-non-recursive-non-empty-dir-del

Conversation

@claucambra
Copy link
Copy Markdown
Contributor

No description provided.

@claucambra claucambra requested a review from Copilot May 9, 2025 04:04
@claucambra claucambra self-assigned this 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 improves deletion handling for non-empty directories by returning an error when attempting a non-recursive delete.

  • Added a new test case to verify non-recursive deletion fails for non-empty directories
  • Updated the delete method to include an options parameter and a guard clause for non-recursive deletion
  • Ensured appropriate metadata handling during delete operations

Reviewed Changes

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

File Description
Tests/NextcloudFileProviderKitTests/ItemDeleteTests.swift Added test case for non-recursive deletion on non-empty directory
Sources/NextcloudFileProviderKit/Item/Item+Delete.swift Updated delete method to check deletion options and return error for non-empty directories
Comments suppressed due to low confidence (1)

Sources/NextcloudFileProviderKit/Item/Item+Delete.swift:27

  • [nitpick] The variable name 'isEmptyDirOrIsFile' could be clearer. Consider renaming it to 'hasNoChildItems' to better convey its purpose.
let isEmptyDirOrIsFile = childItemCount == nil || childItemCount == 0

@claucambra claucambra added this to the 2.1 milestone May 9, 2025
claucambra added 2 commits May 9, 2025 14:16
…f non-empty directory

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
@claucambra claucambra force-pushed the bugfix/handle-non-recursive-non-empty-dir-del branch from 7f98965 to 685bfb6 Compare May 9, 2025 06:16
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.21%. Comparing base (52e92f5) to head (685bfb6).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   81.11%   81.21%   +0.10%     
==========================================
  Files          62       60       -2     
  Lines       13039    13104      +65     
==========================================
+ Hits        10576    10642      +66     
+ Misses       2463     2462       -1     

☔ 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 a4892bb into main May 9, 2025
3 checks passed
@claucambra claucambra deleted the bugfix/handle-non-recursive-non-empty-dir-del branch May 9, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants