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>
This commit is contained in:
parent
e970e9f710
commit
4a73f645e5
|
@ -24,6 +24,7 @@
|
|||
|
||||
namespace OC;
|
||||
|
||||
use OCP\IRequest;
|
||||
use ownCloud\TarStreamer\TarStreamer;
|
||||
use ZipStreamer\ZipStreamer;
|
||||
|
||||
|
@ -34,11 +35,21 @@ class Streamer {
|
|||
// streamer instance
|
||||
private $streamerInstance;
|
||||
|
||||
public function __construct(){
|
||||
/** @var \OCP\IRequest */
|
||||
$request = \OC::$server->getRequest();
|
||||
/**
|
||||
* Streamer constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param int $size The size of the files in bytes
|
||||
*/
|
||||
public function __construct(IRequest $request, int $size){
|
||||
|
||||
if ($request->isUserAgent($this->preferTarFor)) {
|
||||
/**
|
||||
* 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]);
|
||||
|
|
|
@ -144,17 +144,28 @@ class OC_Files {
|
|||
}
|
||||
}
|
||||
|
||||
$streamer = new Streamer();
|
||||
OC_Util::obEnd();
|
||||
|
||||
self::lockFiles($view, $dir, $files);
|
||||
|
||||
/* Calculate filesize */
|
||||
if ($getType === self::ZIP_FILES) {
|
||||
$fileSize = 0;
|
||||
foreach ($files as $file) {
|
||||
$fileSize += \OC\Files\Filesystem::getFileInfo($dir . '/' . $file)->getSize();
|
||||
}
|
||||
} elseif ($getType === self::ZIP_DIR) {
|
||||
$fileSize = \OC\Files\Filesystem::getFileInfo($dir . '/' . $files)->getSize();
|
||||
}
|
||||
|
||||
$streamer = new Streamer(\OC::$server->getRequest(), $fileSize);
|
||||
OC_Util::obEnd();
|
||||
|
||||
$streamer->sendHeaders($name);
|
||||
$executionTime = (int)OC::$server->getIniWrapper()->getNumeric('max_execution_time');
|
||||
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
||||
@set_time_limit(0);
|
||||
}
|
||||
ignore_user_abort(true);
|
||||
|
||||
if ($getType === self::ZIP_FILES) {
|
||||
foreach ($files as $file) {
|
||||
$file = $dir . '/' . $file;
|
||||
|
|
Loading…
Reference in New Issue