Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-08-17 12:13:22 +0300
committerGitHub <noreply@github.com>2022-08-17 12:13:22 +0300
commitba606f1bb3b28e23cd8b0498c4c8359506a66779 (patch)
treec96ae5bdc4d0b196112a37266dff4792d8fe5c99
parenta512a6cceb77e2e914c869f3f745feb504b301b8 (diff)
parentea9509eaf9d6caba28320efa92fc538a8fceaf6c (diff)
Merge pull request #33562 from nextcloud/empty-folder-size-24
[24] fix updating size when folder is empty
-rw-r--r--lib/private/Files/Cache/Cache.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 5dded8c32dd..ed5c40e86d2 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,
+ ]);
}
}
}