From 881e362f932bfd2d3b5daddd83545d09bda16e40 Mon Sep 17 00:00:00 2001 From: Valerio Ponte Date: Fri, 10 May 2013 21:11:47 +0200 Subject: final fix for xsendfile zip generation race condition --- lib/helper.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'lib/helper.php') diff --git a/lib/helper.php b/lib/helper.php index ca508e1d933..056c9a37fe5 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -621,9 +621,26 @@ class OC_Helper { * remove all files in PHP /oc-noclean temp dir */ public static function cleanTmpNoClean() { - $tmpDirNoCleanFile=get_temp_dir().'/oc-noclean/'; - if(file_exists($tmpDirNoCleanFile)) { - self::rmdirr($tmpDirNoCleanFile); + $tmpDirNoCleanName=get_temp_dir().'/oc-noclean/'; + if(file_exists($tmpDirNoCleanName) && is_dir($tmpDirNoCleanName)) { + $files=scandir($tmpDirNoCleanName); + foreach($files as $file) { + $fileName = $tmpDirNoCleanName . $file; + if (!\OC\Files\Filesystem::isIgnoredDir($file) && filemtime($fileName) + 600 < time()) { + unlink($fileName); + } + } + // if oc-noclean is empty delete it + $isTmpDirNoCleanEmpty = true; + $tmpDirNoClean = opendir($tmpDirNoCleanName); + while (false !== ($file = readdir($tmpDirNoClean))) { + if (!\OC\Files\Filesystem::isIgnoredDir($file)) { + $isTmpDirNoCleanEmpty = false; + } + } + if ($isTmpDirNoCleanEmpty) { + rmdir($tmpDirNoCleanName); + } } } -- cgit v1.2.3 From 1e4ebf47e26579d6bd0334b4853ee0c960c1b2a6 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Tue, 27 Aug 2013 00:57:28 +0200 Subject: webdav quota now displays the same values as the web interface does --- lib/connector/sabre/directory.php | 6 +++--- lib/helper.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/helper.php') diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index ed8d085462d..66cd2fcd4e3 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -233,10 +233,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * @return array */ public function getQuotaInfo() { - $rootInfo=\OC\Files\Filesystem::getFileInfo(''); + $storageInfo = OC_Helper::getStorageInfo($this->path); return array( - $rootInfo['size'], - \OC\Files\Filesystem::free_space() + $storageInfo['used'], + $storageInfo['total'] ); } diff --git a/lib/helper.php b/lib/helper.php index c7687d431e1..128786087b8 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -843,13 +843,13 @@ class OC_Helper { /** * Calculate the disc space */ - public static function getStorageInfo() { - $rootInfo = \OC\Files\Filesystem::getFileInfo('/'); + public static function getStorageInfo($path = '/') { + $rootInfo = \OC\Files\Filesystem::getFileInfo($path); $used = $rootInfo['size']; if ($used < 0) { $used = 0; } - $free = \OC\Files\Filesystem::free_space(); + $free = \OC\Files\Filesystem::free_space($path); if ($free >= 0) { $total = $free + $used; } else { -- cgit v1.2.3 From 8cf9336bcbe527c3d3eb7b348f3a0feff799c1da Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Tue, 27 Aug 2013 00:59:58 +0200 Subject: storage information is path specific --- apps/files/index.php | 2 +- apps/files/lib/helper.php | 2 +- lib/helper.php | 7 +++++-- settings/personal.php | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/helper.php') diff --git a/apps/files/index.php b/apps/files/index.php index 94c792303da..e4d8e353858 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -119,7 +119,7 @@ if ($needUpgrade) { $tmpl->printPage(); } else { // information about storage capacities - $storageInfo=OC_Helper::getStorageInfo(); + $storageInfo=OC_Helper::getStorageInfo($dir); $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); if (OC_App::isEnabled('files_encryption')) { diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index f2b1f142e9b..7135ef9f656 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -11,7 +11,7 @@ class Helper $maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize; // information about storage capacities - $storageInfo = \OC_Helper::getStorageInfo(); + $storageInfo = \OC_Helper::getStorageInfo($dir); return array('uploadMaxFilesize' => $maxUploadFilesize, 'maxHumanFilesize' => $maxHumanFilesize, diff --git a/lib/helper.php b/lib/helper.php index 128786087b8..dd2476eda5c 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -841,9 +841,12 @@ class OC_Helper { } /** - * Calculate the disc space + * Calculate the disc space for the given path + * + * @param string $path + * @return array */ - public static function getStorageInfo($path = '/') { + public static function getStorageInfo($path) { $rootInfo = \OC\Files\Filesystem::getFileInfo($path); $used = $rootInfo['size']; if ($used < 0) { diff --git a/settings/personal.php b/settings/personal.php index e69898f6f8f..112eaa3c748 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -17,7 +17,7 @@ OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); OC_Util::addStyle( '3rdparty', 'chosen' ); OC_App::setActiveNavigationEntry( 'personal' ); -$storageInfo=OC_Helper::getStorageInfo(); +$storageInfo=OC_Helper::getStorageInfo('/'); $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); -- cgit v1.2.3