Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/private/Streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}

Expand Down