]> source.dussan.org Git - nextcloud-server.git/commitdiff
Return all keys in getAllVersions() instead 23422/head
authorMorris Jobke <hey@morrisjobke.de>
Fri, 9 Oct 2020 13:23:10 +0000 (15:23 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 13 Oct 2020 15:39:33 +0000 (15:39 +0000)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/files_versions/lib/Storage.php

index 04bfa1c7c3ff4222bb1e6df8d3ca4b3a0752ea5c..43b2fef169c9fea610dbe1513181eff9e5cee41f 100644 (file)
@@ -496,7 +496,7 @@ class Storage {
                $expiration = self::getExpiration();
                $threshold = $expiration->getMaxAgeAsTimestamp();
                $versions = self::getAllVersions($uid);
-               if (!$threshold || !array_key_exists('all', $versions)) {
+               if (!$threshold || empty($versions['all'])) {
                        return;
                }
 
@@ -578,7 +578,10 @@ class Storage {
                // newest version first
                krsort($versions);
 
-               $result = [];
+               $result = [
+                       'all' => [],
+                       'by_file' => [],
+               ];
 
                foreach ($versions as $key => $value) {
                        $size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']);
@@ -775,8 +778,8 @@ class Storage {
 
                        // if still not enough free space we rearrange the versions from all files
                        if ($availableSpace <= 0) {
-                               $result = Storage::getAllVersions($uid);
-                               $allVersions = $result['all'] ?? [];
+                               $result = self::getAllVersions($uid);
+                               $allVersions = $result['all'];
 
                                foreach ($result['by_file'] as $versions) {
                                        list($toDeleteNew, $size) = self::getExpireList($time, $versions, $availableSpace <= 0);