Skip to content
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

Merged
merged 2 commits into from Jan 15, 2015
Merged

Fix #6927 race conditions when deleting files #6990

merged 2 commits into from Jan 15, 2015

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Jan 13, 2015

See #6927

@mnapoli mnapoli added the Bug For errors / faults / flaws / inconsistencies etc. label Jan 13, 2015
@mnapoli mnapoli added this to the Piwik 2.11.0 milestone Jan 13, 2015
@mattab
Copy link
Member

mattab commented Jan 14, 2015

Hi @diosmosis pls review that one

Filesystem::remove($this->getAbsoluteLocation() . ".deflate");
Filesystem::remove($this->getAbsoluteLocation() . ".gz");
} catch (Exception $e) {
}
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

diosmosis added a commit that referenced this pull request Jan 15, 2015
Fix #6927 race conditions when deleting files
@diosmosis diosmosis merged commit 74b2956 into master Jan 15, 2015
@diosmosis diosmosis deleted the bug/6927 branch January 15, 2015 13:36
@mnapoli mnapoli self-assigned this Jan 15, 2015
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Feb 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants