-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix: file deletion called twice and ignoring errors with FileSystem storage type #35905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 41b1d9c The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #35905 +/- ##
===========================================
- Coverage 64.73% 64.71% -0.02%
===========================================
Files 3106 3107 +1
Lines 92877 93094 +217
Branches 17675 17775 +100
===========================================
+ Hits 60127 60250 +123
- Misses 29964 30056 +92
- Partials 2786 2788 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Handles potential errors during file deletion within the prune history functionality. If file deletion fails during the prune history process, it now stores the failed files instead of deleting the message attachment in the database. Updates tests to reflect changes to the pruning process.
…nto SUP-745-fix-pruning-ufs-local
Refactors the rooms.cleanHistory API endpoint to directly pass parameters to the cleanRoomHistoryMethod, removing unnecessary parameter object creation. Removes filesOnly property from the API response as it is no longer needed.
…nto SUP-745-fix-pruning-ufs-local
…nto SUP-745-fix-pruning-ufs-local
Does this really "fix" the issue? Or is it a better version of the old code i.e. with better logging? I'm asking because i don't necessarily see any change that makes it actually delete things, not do I see the old code not deleting things. Unless stat fails both times (first actual call, second i don't know why, but regardless). If so do you know why? |
@debdutdeb there's a root cause analysis in the ticket and 3 other related tickets which were part of the issue and were merged (especially #35797 which clears the files array). About the improvements here: the old code would call delete twice, and there are possible race conditions between stat and unlink. There's no reason to call stat since unlink will perform the same pre-conditions and throw. Indeed there's no way to fully guarantee deletion, but now we'll see real errors if something goes wrong (except for the file not existing, which is expected in some cases like changing Maybe this PR can be renamed. |
I think it makes sense to rename it @cardoso, maybe a chore instead? |
@MarcosSpessatto I updated the name already to match what's being done:
I think it's better to keep it as a fix, but I can change to chore if you prefer. |
Proposed changes (including videos or screenshots)
Removes the call to fs.stat to check if the file existed and is a file (using isFile()) before attempting to delete it. This was done asynchronously and, if the file existed and was a file, it would then call fs.unlink to delete it.
Instead, the code now directly attempts to delete the file using unlink(path). If the file does not exist (ENOENT), the error is safely ignored.
This change also helps prevent race conditions where the file could be deleted between the stat and unlink calls.
Also fixes the delete method being called twice.
Issue(s)
https://rocketchat.atlassian.net/browse/SUP-745
Steps to test or reproduce
Further comments