diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-04-16 13:52:46 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-04-17 10:43:12 +0200 |
commit | ddde1b65db36507b30aa42e991c9b50312f7c97f (patch) | |
tree | 74ef760c0a88a2d97149e9891e99fc9a1f92f8f8 /apps | |
parent | a3999036f720e73727dac07a337578f3e25f92aa (diff) | |
download | nextcloud-server-ddde1b65db36507b30aa42e991c9b50312f7c97f.tar.gz nextcloud-server-ddde1b65db36507b30aa42e991c9b50312f7c97f.zip |
adapt free space calculation to the way it is done for the trash bin
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_versions/lib/versions.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 47d044873ad..c38ba688fe0 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -378,12 +378,14 @@ class Storage { $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); // get available disk space for user + $softQuota = true; $quota = \OC_Preferences::getValue($uid, 'files', 'quota'); if ( $quota === null || $quota === 'default') { $quota = \OC_Appconfig::getValue('files', 'default_quota'); } if ( $quota === null || $quota === 'none' ) { - $quota = \OC\Files\Filesystem::free_space('/') / count(\OCP\User::getUsers()); + $quota = \OC\Files\Filesystem::free_space('/'); + $softQuota = false; } else { $quota = \OCP\Util::computerFileSize($quota); } @@ -397,15 +399,21 @@ class Storage { } // calculate available space for version history - $files_view = new \OC\Files\View('/'.$uid.'/files'); - $rootInfo = $files_view->getFileInfo('/'); - $free = $quota-$rootInfo['size']; // remaining free space for user - if ( $free > 0 ) { - $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $versionsSize; // how much space can be used for versions + // subtract size of files and current versions size from quota + if ($softQuota) { + $files_view = new \OC\Files\View('/'.$uid.'/files'); + $rootInfo = $files_view->getFileInfo('/'); + $free = $quota-$rootInfo['size']; // remaining free space for user + if ( $free > 0 ) { + $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $versionsSize; // how much space can be used for versions + } else { + $availableSpace = $free-$versionsSize; + } } else { - $availableSpace = $free-$versionsSize; + $availableSpace = $quota; } + // after every 1000s run reduce the number of all versions not only for the current file $random = rand(0, 1000); if ($random == 0) { |