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

prevent 0 byte downloads when storage returns false #19081

Merged
merged 2 commits into from
Sep 21, 2015

Conversation

butonic
Copy link
Member

@butonic butonic commented Sep 16, 2015

ref #17220
prevents data loss

@PVince81
Copy link
Contributor

Makes sense. A unit test would be nice 😄

@icewind1991
Copy link
Contributor

Added unit tests, code looks good 👍

@PVince81
Copy link
Contributor

Thanks 👍

@PVince81 PVince81 added this to the 8.2-current milestone Sep 16, 2015
@butonic
Copy link
Member Author

butonic commented Sep 17, 2015

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");
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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 💩

Copy link
Contributor

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

Copy link
Member Author

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.

@nickvergessen
Copy link
Contributor

👍

icewind1991 added a commit that referenced this pull request Sep 21, 2015
prevent 0 byte downloads when storage returns false
@icewind1991 icewind1991 merged commit b520a1e into master Sep 21, 2015
@icewind1991 icewind1991 deleted the prevent0bytedownloads branch September 21, 2015 11:50
@PVince81
Copy link
Contributor

@karlitschek backport to 8.0 and 8.1 ?

@PVince81
Copy link
Contributor

stable8.1: #21296
stable8: #21297

@karlitschek
Copy link
Contributor

please backport 👍

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants