summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2013-08-29 10:50:55 +0200
committerGeorg Ehrke <developer@georgehrke.com>2013-08-29 10:50:55 +0200
commitb7758d0f8d52b2f9653cfee549558327c00c8e01 (patch)
tree309fb713ed25f35f746c59c668521bf9023bc331 /lib/helper.php
parent70b6e2161ec654f7049027bf6dc5072c1eda4d5e (diff)
parentea6e74ca9546ca95b3a6372c6106cd8ab2ea2ee9 (diff)
downloadnextcloud-server-b7758d0f8d52b2f9653cfee549558327c00c8e01.tar.gz
nextcloud-server-b7758d0f8d52b2f9653cfee549558327c00c8e01.zip
Merge master into oc_preview
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 4c3415f4afa..afeb3771048 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -637,9 +637,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);
+ }
}
}
@@ -870,15 +887,18 @@ class OC_Helper {
}
/**
- * Calculate the disc space
+ * Calculate the disc space for the given path
+ *
+ * @param string $path
+ * @return array
*/
- 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 {