From 1e453ff55439a6a64a7a2111086507addc374711 Mon Sep 17 00:00:00 2001 From: Juri Berlanda Date: Fri, 18 Jun 2021 18:05:32 +0200 Subject: [PATCH 1/2] Rework how archive type (ZIP or TAR) is chosen. There is an issue when downloading large folders (i.e. bigger than 2GB) as archives. This commit tries to improve the situation. Signed-off-by: Juri Berlanda --- lib/private/Streamer.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php index 176334b971df4..b6fb0fcff0687 100644 --- a/lib/private/Streamer.php +++ b/lib/private/Streamer.php @@ -81,12 +81,20 @@ public function __construct(IRequest $request, int $size, int $numberOfFiles) { * from not fully scanned external storage. And then things fall apart * if somebody tries to package to much. */ - if ($size > 0 && $size < 4 * 1000 * 1000 * 1000 && $numberOfFiles < 65536) { - $this->streamerInstance = new ZipStreamer(['zip64' => false]); - } elseif ($request->isUserAgent($this->preferTarFor)) { + + // Use TAR no matter what if that is preferred for the current user agent + if ($request->isUserAgent($this->preferTarFor)) { $this->streamerInstance = new TarStreamer(); + // Zip32 as default if size and numberOfFiles allow it + } elseif ($size > 0 && $size < 4 * 1000 * 1000 * 1000 && $numberOfFiles < 65536) { + $this->streamerInstance = new ZipStreamer(['zip64' => false]); + // TODO: Depending on Zip64 support - not sure how one would correctly determine that } else { - $this->streamerInstance = new ZipStreamer(['zip64' => PHP_INT_SIZE !== 4]); + if (PHP_INT_SIZE !== 4) { + $this->streamerInstance = new ZipStreamer(['zip64' => true]); + } else { + $this->streamerInstance = new TarStreamer(); + } } } From 2b351aaa3ea753b004c1745f9e62c383aea6b5d1 Mon Sep 17 00:00:00 2001 From: Juri Berlanda Date: Fri, 18 Jun 2021 18:06:10 +0200 Subject: [PATCH 2/2] Prefer TAR for Linux'user agents. Signed-off-by: Juri Berlanda --- lib/private/Streamer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php index b6fb0fcff0687..af45c3afb1b21 100644 --- a/lib/private/Streamer.php +++ b/lib/private/Streamer.php @@ -40,7 +40,7 @@ class Streamer { // array of regexp. Matching user agents will get tar instead of zip - private $preferTarFor = [ '/macintosh|mac os x/i' ]; + private $preferTarFor = [ '/macintosh|mac os x|linux/i' ]; // streamer instance private $streamerInstance;