Skip to content
Snippets Groups Projects
Commit 546fb72b authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Merge pull request #2165 from owncloud/fix_2155

Offer download of whole shared dir only if it does not exceed zip input ...
parents f9c24a03 f4a32617
Branches
No related tags found
No related merge requests found
...@@ -141,7 +141,9 @@ if (isset($path)) { ...@@ -141,7 +141,9 @@ if (isset($path)) {
OCP\Util::addscript('files', 'keyboardshortcuts'); OCP\Util::addscript('files', 'keyboardshortcuts');
$files = array(); $files = array();
$rootLength = strlen($basePath) + 1; $rootLength = strlen($basePath) + 1;
$totalSize = 0;
foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) { foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
$totalSize += $i['size'];
$i['date'] = OCP\Util::formatDate($i['mtime']); $i['date'] = OCP\Util::formatDate($i['mtime']);
if ($i['type'] == 'file') { if ($i['type'] == 'file') {
$fileinfo = pathinfo($i['name']); $fileinfo = pathinfo($i['name']);
...@@ -188,7 +190,9 @@ if (isset($path)) { ...@@ -188,7 +190,9 @@ if (isset($path)) {
$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$folder->assign('usedSpacePercent', 0); $folder->assign('usedSpacePercent', 0);
$tmpl->assign('folder', $folder->fetchPage()); $tmpl->assign('folder', $folder->fetchPage());
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $allowZip = OCP\Config::getSystemValue('allowZipDownload', true)
&& $totalSize <= OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'));
$tmpl->assign('allowZipDownload', intval($allowZip));
$tmpl->assign('downloadURL', $tmpl->assign('downloadURL',
OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath));
} else { } else {
......
...@@ -219,12 +219,18 @@ class OC_Files { ...@@ -219,12 +219,18 @@ class OC_Files {
$zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB')); $zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if ($zipLimit > 0) { if ($zipLimit > 0) {
$totalsize = 0; $totalsize = 0;
if (is_array($files)) { if(!is_array($files)) {
$files = array($files);
}
foreach ($files as $file) { foreach ($files as $file) {
$totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $file); $path = $dir . '/' . $file;
if(\OC\Files\Filesystem::is_dir($path)) {
foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
$totalsize += $i['size'];
} }
} else { } else {
$totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $files); $totalsize += \OC\Files\Filesystem::filesize($path);
}
} }
if ($totalsize > $zipLimit) { if ($totalsize > $zipLimit) {
$l = OC_L10N::get('lib'); $l = OC_L10N::get('lib');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment