Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix updating size when folder is empty
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 16, 2022
commit de63f6363f1ae590c9735fbe9592835c04ab32cd
30 changes: 17 additions & 13 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ public function calculateFolderSize($path, $entry = null) {
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);
Expand All @@ -913,18 +913,22 @@ public function calculateFolderSize($path, $entry = null) {
} 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,
]);
}
}
}
Expand Down