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

[HttpFoundation] Check file exists before unlink #29764

Merged
merged 1 commit into from Jan 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -305,7 +305,7 @@ public function sendContent()
fclose($out);
fclose($file);

if ($this->deleteFileAfterSend) {
if ($this->deleteFileAfterSend && file_exists($this->file->getPathname())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doenst fopen already fail in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file can be deleted after fopen() while it is being sent to the user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got ya :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the file could also be removed between the calls to file_exists() and unlink(). Maybe it would be better to silence the delete operation instead.

Copy link
Contributor Author

@ad-mos ad-mos Jan 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloading is a much longer process than file_exists()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I do not think that @unlink($this->file->getPathname()); would be a good solution here, it will ignore all errors, and not just 'No such file or directory'.
What else needs to be done for this to be merged ?

unlink($this->file->getPathname());
}

Expand Down