aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-01-20 11:41:04 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-06 15:59:30 +0200
commit4a73f645e5a60d8adece72e6c231c2a1be13473d (patch)
treea9787088b5307f8b19e6a269f60bf42346a673b7 /lib
parente970e9f7106c094d49fd3ed49244fb073b97e381 (diff)
downloadnextcloud-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')
-rw-r--r--lib/private/Streamer.php23
-rw-r--r--lib/private/legacy/files.php17
2 files changed, 31 insertions, 9 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]);
diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php
index def9f82fab9..b7c99b7fef8 100644
--- a/lib/private/legacy/files.php
+++ b/lib/private/legacy/files.php
@@ -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;