-
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
Download directory as zip while an inner file is being overwritten causes the download to be corrupted #16960
Comments
Not sure what to do in this case. Either the zip process must skip the file because it's locked, or abort completely with a locked exception + 423 status code. |
Abort is probably the best |
Hmmm, this shouldn't happen, the zip related code uses View::fopen here https://github.com/owncloud/core/blob/master/lib/private/files.php#L156 which should try and lock the file. Maybe the exception got caught and the error page got appended into the zip file ? |
Zip files are created on the fly and streamed back to the client, while adding each file one by one. Additionally since we cannot predict the response length, we cannot pre-set the "Content-Length" header that might hint clients that pieces of the file is missing. So the aborting approach seems quite tricky. Let's try another approach: before downloading the folder, set a share lock on the folder. This should prevent files to be uploaded there while the zip file is created. Note that this could take a while, so the folder might be locked for a long time. CC @icewind1991 |
A quick discussion with @icewind1991 pointed me at rather trying to set a shared lock on every file inside the folder recursively. Other ways would not properly prevent people to change contents during the download. I could even make it progressive: first set a shared lock on ALL files inside. And then, as the files are delivered one by one, unlock them one by one to make them available to others. |
That's exactly what I was thinking. It looks the best approach 👏 If by chance we can't get the lock of any file, we'll just need to unlock all the locks and throw the locked exception |
Yes. The way it currently works is that if any exception happens in the middle, any lock will automatically be freed a the end of the PHP process (shutdown handler), so no additional code is required for such cases. |
This problem has also happened while 'getPath' is returned "" string. I will make another issue ticket. |
add another issue ticket. |
Steps for the implementation:
|
This is a known issue from the very first day when zip download was introduced - not regression - nothing we can do short hand -> 8.2 |
Well, the locking is something new, a new situation where the zip file can be corrupted and it might happen more often. But anyway, I have conflicting views regarding this static Files class which we'll want to kill eventually, so it's best to defer this. |
Let's see if we can add locking once we have #19318 in place |
This is merged now - we can now integrate locking on the file list. |
Steps to reproduce
Expected behaviour
A locked exception should be thrown
Actual behaviour
A corrupted zip file is downloaded.
Server configuration
Operating system: ubuntu 14.04
Web server: apache 2.4.7
Database: mysql
PHP version: 5.5.9
ownCloud version: 8.1 beta 2 (daily) Build:2015-06-12T03:13:02+00:00 cda9685
Updated from an older ownCloud or fresh install: fresh install
The text was updated successfully, but these errors were encountered: