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
Fix #6927 race conditions when deleting files #6990
Conversation
Hi @diosmosis pls review that one |
Filesystem::remove($this->getAbsoluteLocation() . ".deflate"); | ||
Filesystem::remove($this->getAbsoluteLocation() . ".gz"); | ||
} catch (Exception $e) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surrounding the calls in a try-catch every time we want to ignore unlink failures seems excessive... Maybe instead there can be two methods 'tryRemove' and 'remove'? tryRemove would do the same logic as remove now but return true/false based on whether remove succeeds or not. remove would use tryRemove and if false, throws.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that makes sense. But is that very common to remove files but not actually care if they are really deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but I would assume in most cases we wouldn't want a failed remove to result in an exception that causes the request to fail. So there may be custom error handling, and using a try-catch every time for something as simple as file deletion seems verbose to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the code to optionally log a warning instead of throwing an exception. I've used a method parameter instead of defining a new method to avoid creating too many similar methods.
Fix #6927 race conditions when deleting files
See #6927