fix(filesystem): improve file deletion error handling#1217
Conversation
WalkthroughThe changes refactor file deletion logic in Changes
Sequence Diagram(s)sequenceDiagram
participant Code as Calling Code
participant FS as std::filesystem
participant Logger as Logger
Code->>FS: remove(path, error_code)
alt error_code indicates error
FS-->>Logger: Log warning with error message
else file removed
FS-->>Logger: Log debug message (deleted)
else file not removed, no error
FS-->>Logger: (No log, treat as file not existing)
end
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
✅ A pre-release build is available for this PR: |
alandtse
left a comment
There was a problem hiding this comment.
Can you explain why you prefer to remove an existence check? Seems odd to blind delete things. It's not like this is a hot path where the io really matters to check existence vs delete.
The method returns false if the file did not exist. |
|
That's not really answering my question. |
|
Like if it's the new cpp approach to delete without checking existence then fine, but I need to understand your reasoning. |
The existence check is redundant because the solution proposed already has handling built in for not-existent files. Removing the check means we don't sacrifice functionality, or add risk, and simplifies the file deletion code. |
|
@soda3000 Please revert the merge commit and then force push so it's only your changes and not all of dev. It'll cause conflicts. |
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
@coderabbitai is this a fix? |
|
Tip For best results, initiate chat on the files or code changes. @alandtse Yes, this appears to be appropriately classified as a "fix" based on conventional commits standards. The changes address deficiencies in the existing file deletion error handling by:
Since this corrects existing functionality rather than adding new features, and addresses a specific issue with inadequate error handling, the "fix" classification is defensible under conventional commits standards. thinking deeply ✏️ Learnings added
🧠 Learnings used |
Closes #1180
Summary:
std::filesystem::remove’s return value instead of a priorexists()checkremove()returns false (no file removed)Summary by CodeRabbit