summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorVictor Dubiniuk <victor.dubiniuk@gmail.com>2015-08-19 00:00:18 +0300
committerVictor Dubiniuk <victor.dubiniuk@gmail.com>2015-09-15 17:08:54 +0300
commitb95d1e668370c74d027330cdabe5e65e242ef18d (patch)
tree6f142a0a2d5836393be5ea413832ace03cafc761 /apps/files_versions
parent7ef937d8ad33ed2cd3e452bcde386e9d125e6a54 (diff)
downloadnextcloud-server-b95d1e668370c74d027330cdabe5e65e242ef18d.tar.gz
nextcloud-server-b95d1e668370c74d027330cdabe5e65e242ef18d.zip
Add quota status to expiration check
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/storage.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index b190ea307e2..269d43befb8 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -482,25 +482,25 @@ class Storage {
* @param integer $time
* @return array containing the list of to deleted versions and the size of them
*/
- protected static function getExpireList($time, $versions) {
+ protected static function getExpireList($time, $versions, $quotaExceeded = false) {
$application = new Application();
$expiration = $application->getContainer()->query('Expiration');
if ($expiration->shouldAutoExpire()) {
- return self::getAutoExpireList($time, $versions);
+ list($toDelete, $size) = self::getAutoExpireList($time, $versions);
+ } else {
+ $size = 0;
+ $toDelete = []; // versions we want to delete
}
- $size = 0;
- $toDelete = []; // versions we want to delete
-
foreach ($versions as $key => $version) {
- if ($expiration->isExpired($version['version'])) {
- $toDelete[$key] = $version['path'] . '.v' . $version['version'];
+ if ($expiration->isExpired($version['version'], $quotaExceeded) && !isset($toDelete[$key])) {
$size += $version['size'];
+ $toDelete[$key] = $version['path'] . '.v' . $version['version'];
}
}
- return array($toDelete, $size);
+ return [$toDelete, $size];
}
/**
@@ -633,7 +633,7 @@ class Storage {
$allVersions = Storage::getVersions($uid, $filename);
$time = time();
- list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions);
+ list($toDelete, $sizeOfDeletedVersions) = self::getExpireList($time, $allVersions, $availableSpace <= 0);
$availableSpace = $availableSpace + $sizeOfDeletedVersions;
$versionsSize = $versionsSize - $sizeOfDeletedVersions;
@@ -644,7 +644,7 @@ class Storage {
$allVersions = $result['all'];
foreach ($result['by_file'] as $versions) {
- list($toDeleteNew, $size) = self::getExpireList($time, $versions);
+ list($toDeleteNew, $size) = self::getExpireList($time, $versions, $availableSpace <= 0);
$toDelete = array_merge($toDelete, $toDeleteNew);
$sizeOfDeletedVersions += $size;
}