diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-20 11:41:04 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-06 15:59:30 +0200 |
commit | 4a73f645e5a60d8adece72e6c231c2a1be13473d (patch) | |
tree | a9787088b5307f8b19e6a269f60bf42346a673b7 /lib/private/Streamer.php | |
parent | e970e9f7106c094d49fd3ed49244fb073b97e381 (diff) | |
download | nextcloud-server-4a73f645e5a60d8adece72e6c231c2a1be13473d.tar.gz nextcloud-server-4a73f645e5a60d8adece72e6c231c2a1be13473d.zip |
Use zip32 if possible
* OSX doesn't handle 64zip that well
* Some other implentations don't handle it perfectly either
* If the file is belog 4GiB (some overhead) => zip32
* This covers the 99% case I bet
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Streamer.php')
-rw-r--r-- | lib/private/Streamer.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php index 7b178fda652..3b033e265e7 100644 --- a/lib/private/Streamer.php +++ b/lib/private/Streamer.php @@ -24,6 +24,7 @@ namespace OC; +use OCP\IRequest; use ownCloud\TarStreamer\TarStreamer; use ZipStreamer\ZipStreamer; @@ -33,12 +34,22 @@ class Streamer { // streamer instance private $streamerInstance; - - public function __construct(){ - /** @var \OCP\IRequest */ - $request = \OC::$server->getRequest(); - - if ($request->isUserAgent($this->preferTarFor)) { + + /** + * Streamer constructor. + * + * @param IRequest $request + * @param int $size The size of the files in bytes + */ + public function __construct(IRequest $request, int $size){ + + /** + * If the size if below 4GB always use zip32 + * Use 4*1000*1000*1000 so we have a buffer for all the extra zip data + */ + if ($size < 4 * 1000 * 1000 * 1000) { + $this->streamerInstance = new ZipStreamer(['zip64' => false]); + } else if ($request->isUserAgent($this->preferTarFor)) { $this->streamerInstance = new TarStreamer(); } else { $this->streamerInstance = new ZipStreamer(['zip64' => PHP_INT_SIZE !== 4]); |