refactored/cleaned up lib/private/files.php and switched get() to ZipStreamer#6893
refactored/cleaned up lib/private/files.php and switched get() to ZipStreamer#6893McNetic wants to merge 3 commits intoowncloud:masterfrom
Conversation
cleaned up get() logic fixed get() to only send headers if requested (xsendfile could get in the way) do no longer readfile() when already using mod_xsendfile or similar
|
Thanks a lot for your contribution! Contributions to the core repo require a signed contributors agreement http://owncloud.org/about/contributor-agreement/ Alternatively you can add a comment here where you state that this contribution is MIT licensed. Some more details about out pull request workflow can be found here: http://owncloud.org/code-reviews-on-github/ |
|
Contributor agreement was sent by mail. I'm not exactly sure what to do about the second pull request (the one for 3rdparty). Is that all necessary? If yes, it has to be updated, to, to incorporate witchis changes and some more from me, too. I also want to add that currently (with the Zip64-support as far as I understand), this only works on a 64-bit machine. It effectively imposes this restriction on the whole owncloud, as long as zip download is used. I just started a correspondence with witchi to clear this up. |
There was a problem hiding this comment.
What about autoloading?
@DeepDiver1975 You know how to do this with external libraries, right? :)
There was a problem hiding this comment.
We have to add the ZipStreamer to the 3rdparty repo - preferably we use composer to load it there.
Composer will take case of proper autoloading.
There was a problem hiding this comment.
Ping me in case you need support to bring ZipStreamer to the 3rdparty repo
@McNetic Can you please explain the background in technical terms here? See report in #7138 for how floats can be used to represent filesize. |
|
-----BEGIN PGP SIGNED MESSAGE-----
It was indeed about the file sizes. As the Zip64 extension is now As ZipStreamer does not read file sizes, and does process files The only limitation in 32bit machines now should be the LFS support. NB: The content-length, of course, can not be advertised with streamed iEYEARECAAYFAlMDge0ACgkQYm+MkvsfJ5+UhgCg3PM99I/i8usAdwru9WylCk8w |
|
@DeepDiver1975: I just now understood you may have meant me with your offer to help bring ZipStreamer to 3rdparty. I would be glad if you could do that. I'm not really into owncloud very much, and it's just a side project for me. I'd like to concentrate on the technical side of the zip implementation, if possible. |
Are you sure? Even without compression? |
|
|
@McNetic Since you're probably most familiar with the ZIP format: Do you think it is impossible to pre-calculate the size of the generated zip or do you think it is just not worth it? I mean, because there is no compression involved, my naive approach would be to just use two passes. The first pass would only get all filesizes and calculate the size of the zip. From an architectural point, I would like to note that it is usually not a good idea to do too much work in the constructor of a class. Especially performing output generation, e.g. calling header(), will limit future extensibility of your class. The constructor should setup dependencies only. Another probably complex question: Is the process of zip generation deterministic such that partial downloads could (in theory) be resumed? Thanks a lot. |
So you're right, it should be possible to pre-calculate the file size.
As you can see, both features (size calculation and resuming) are not |
|
I was thinking more about this in the meantime as well. When the filesize is advertised problems may occur when files change between filesize determination and file reading. I think this is probably my biggest concern. I don't think that getting the correct filesize and getting it into the correct format is a big problem. |
|
From a usage perspective, I had something like this in mind: This way, a second pass could be added to stream() easily. |
|
It does have to do with zip streaming. Say in the first pass you see a file as 1000 bytes, then you calculate the filesize of the zip. And then you actually read the file until eof, but now it has 2000 bytes. Thus your filesize of the zip is wrong, if you read the file 2000 bytes file completely.
I meant "big problem", sorry. Corrected above. |
|
|
Regarding your usage perspective: Yes, that's what I meant by building an internal file structure As you can see, what you propose is a quite different approach. It has |
|
I'm hijacking this pull request |
|
@DeepDiver1975 Can you then mention the PR here as it is ready. Thanks :) |
This commit mainly adds the ability for owncloud to use ZipStreamer instead of the builtin ZipArchive. This reduces disk i/o greatly, as the current implementation creates one temp file for each file to be added to the zip, and then again a temp file of the complete zip, before starting to send the temp zip to the client.
The ZipStreamer creates the zip file on the fly in memory and directly sends the data to the client, no temp file needed at all. The ZipStreamer class was added in a second pull request to 3rdparty.
(this is a replacement for pull request #3439)