diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-16 11:16:14 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-08-16 13:54:26 +0200 |
commit | de63f6363f1ae590c9735fbe9592835c04ab32cd (patch) | |
tree | 9b01463e8a05d6084bd9e30d3f558ee220c64d83 /lib/private | |
parent | 1374cbee3e5d44ecec0a0784b3ab3a5afcc0d2ac (diff) | |
download | nextcloud-server-de63f6363f1ae590c9735fbe9592835c04ab32cd.tar.gz nextcloud-server-de63f6363f1ae590c9735fbe9592835c04ab32cd.zip |
fix updating size when folder is empty
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 51008896373..ec284282178 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -891,7 +891,7 @@ class Cache implements ICache { return (int)$row['unencrypted_size']; }, $rows); $unencryptedSizes = array_map(function (array $row) { - return (int)(($row['unencrypted_size'] > 0) ? $row['unencrypted_size']: $row['size']); + return (int)(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']); }, $rows); $sum = array_sum($sizes); @@ -913,18 +913,22 @@ class Cache implements ICache { } else { $unencryptedTotal = $unencryptedSum; } - if ($entry['size'] !== $totalSize) { - // only set unencrypted size for a folder if any child entries have it set - if ($unencryptedMax > 0) { - $this->update($id, [ - 'size' => $totalSize, - 'unencrypted_size' => $unencryptedTotal, - ]); - } else { - $this->update($id, [ - 'size' => $totalSize, - ]); - } + } else { + $totalSize = 0; + $unencryptedTotal = 0; + $unencryptedMax = 0; + } + if ($entry['size'] !== $totalSize) { + // only set unencrypted size for a folder if any child entries have it set, or the folder is empty + if ($unencryptedMax > 0 || $totalSize === 0) { + $this->update($id, [ + 'size' => $totalSize, + 'unencrypted_size' => $unencryptedTotal, + ]); + } else { + $this->update($id, [ + 'size' => $totalSize, + ]); } } } |