summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-02-25 07:59:09 -0800
committerBjörn Schießle <bjoern@schiessle.org>2013-02-25 07:59:09 -0800
commitede0e7d6bc6f317c0e548f9e85dff33a6f3b6337 (patch)
tree64521ca92cf538edb9cb47cb6502dacd40961b06
parent3ef8c0bda3e264ad9f941e6d1c3a49eae3ec92ee (diff)
parentb917646516b7a5756992f6606a601efc480d0872 (diff)
downloadnextcloud-server-ede0e7d6bc6f317c0e548f9e85dff33a6f3b6337.tar.gz
nextcloud-server-ede0e7d6bc6f317c0e548f9e85dff33a6f3b6337.zip
Merge pull request #1890 from owncloud/trashbin_fix
fix quota calculation for trash bin and versions
-rw-r--r--apps/files_trashbin/lib/trash.php12
-rw-r--r--apps/files_versions/lib/versions.php10
2 files changed, 12 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 8f745f82032..d4d5ad96cfa 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -77,7 +77,7 @@ class Trashbin {
if ( $view->is_dir('files_versions'.$file_path) ) {
$trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path));
$view->rename('files_versions'.$file_path, 'files_trashbin/versions'. $deleted.'.d'.$timestamp);
- } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {
+ } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($user, $file_path) ) {
foreach ($versions as $v) {
$trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']);
$view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'files_trashbin/versions'. $deleted.'.v'.$v['version'].'.d'.$timestamp);
@@ -96,20 +96,21 @@ class Trashbin {
$view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.key.d'.$timestamp);
}
}
-
} else {
\OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR);
}
// get available disk space for user
- $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota'));
+ $quota = \OC_Preferences::getValue($user, 'files', 'quota');
if ( $quota === null ) {
- $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota'));
+ $quota = \OC_Appconfig::getValue('files', 'default_quota');
}
if ( $quota === null ) {
$quota = \OC\Files\Filesystem::free_space('/') / count(\OCP\User::getUsers());
+ } else {
+ $quota = \OCP\Util::computerFileSize($quota);
}
-
+
// calculate available space for trash bin
$rootInfo = $view->getFileInfo('/files');
$free = $quota-$rootInfo['size']; // remaining free space for user
@@ -118,7 +119,6 @@ class Trashbin {
} else {
$availableSpace = $free-$trashbinSize;
}
-
$trashbinSize -= self::expire($availableSpace);
self::setTrashbinSize($user, $trashbinSize);
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 05c1bf53e43..778fefd8a72 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -350,12 +350,14 @@ class Storage {
$versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
// get available disk space for user
- $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($uid, 'files', 'quota'));
- if ( $quota == null ) {
- $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota'));
+ $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
+ if ( $quota === null ) {
+ $quota = \OC_Appconfig::getValue('files', 'default_quota');
}
- if ( $quota == null ) {
+ if ( $quota === null ) {
$quota = \OC\Files\Filesystem::free_space('/') / count(\OCP\User::getUsers());
+ } else {
+ $quota = \OCP\Util::computerFileSize($quota);
}
// make sure that we have the current size of the version history