-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
prevent 0 byte downloads when storage returns false #19081
Conversation
Makes sense. A unit test would be nice 😄 |
Added unit tests, code looks good 👍 |
Thanks 👍 |
thx! |
return $this->fileView->fopen(ltrim($this->path, '/'), 'rb'); | ||
$res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb'); | ||
if ($res === false) { | ||
throw new ServiceUnavailable("Could not open file"); |
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.
ServiceUnavailable? in case the file is not there we should return NotFound
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.
This is a fallback for storages that do not throw an exception when there is a infrastructure problem, eg wnd returns false when DNS is not available. There might be other implementations that swallow this kind of problem, leading to 0 byte downloads.
It depends on what we want the client to do. He did a directory listing and now wants to download the file. ServiceUnavailable will make him try the sync again. I don't know what happens when the file has gone. I fear it will locally delete the file, which is what we should avoid to prevent data loss.
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.
bääääh .... we have to catch this on the storage implementation .... such guessing on what the problem might be is 💩
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.
As for the NotFound, sabre already throws that if the file is not found
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.
The problem only surfaces because the code path in our sabre connector never checks the return value of fopen after it checked the stat for it. the file view does ... so ... i think this is the right place.
74738d9
to
2839ef3
Compare
👍 |
prevent 0 byte downloads when storage returns false
@karlitschek backport to 8.0 and 8.1 ? |
please backport 👍 |
ref #17220
prevents data loss