mirror of
https://github.com/nextcloud/server.git
synced 2026-04-26 00:27:49 -04:00
fix unencrypted_size for folders when scanning the filesystem with encryption enabled
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
59d0e7711d
commit
63fb33538c
2 changed files with 16 additions and 6 deletions
|
|
@ -954,9 +954,11 @@ class Cache implements ICache {
|
|||
$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) {
|
||||
|
||||
// only set unencrypted size for a folder if any child entries have it set, or the folder is empty
|
||||
$shouldWriteUnEncryptedSize = $unencryptedMax > 0 || $totalSize === 0;
|
||||
if ($entry['size'] !== $totalSize || ($entry['unencrypted_size'] !== $unencryptedTotal && $shouldWriteUnEncryptedSize)) {
|
||||
if ($shouldWriteUnEncryptedSize) {
|
||||
$this->update($id, [
|
||||
'size' => $totalSize,
|
||||
'unencrypted_size' => $unencryptedTotal,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
namespace OC\Files\Cache;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use OC\Files\Storage\Wrapper\Encryption;
|
||||
use OCP\Files\Cache\IScanner;
|
||||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\Storage\IReliableEtagStorage;
|
||||
|
|
@ -219,7 +220,7 @@ class Scanner extends BasicEmitter implements IScanner {
|
|||
$newData['parent'] = $parentId;
|
||||
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
|
||||
}
|
||||
|
||||
|
||||
$data['oldSize'] = ($cacheData && isset($cacheData['size'])) ? $cacheData['size'] : 0;
|
||||
|
||||
if ($cacheData && isset($cacheData['encrypted'])) {
|
||||
|
|
@ -390,8 +391,15 @@ class Scanner extends BasicEmitter implements IScanner {
|
|||
}
|
||||
}
|
||||
$oldSize = $data['size'] ?? null;
|
||||
if ($this->cacheActive && $oldSize !== $size) {
|
||||
$this->cache->update($folderId, ['size' => $size]);
|
||||
|
||||
// for encrypted storages, we trigger a regular folder size calculation instead of using the calculated size
|
||||
// to make sure we also updated the unencrypted-size where applicable
|
||||
if ($this->storage->instanceOfStorage(Encryption::class)) {
|
||||
$this->cache->calculateFolderSize($path);
|
||||
} else {
|
||||
if ($this->cacheActive && $oldSize !== $size) {
|
||||
$this->cache->update($folderId, ['size' => $size]);
|
||||
}
|
||||
}
|
||||
$this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', [$path, $this->storageId]);
|
||||
return $size;
|
||||
|
|
|
|||
Loading…
Reference in a new issue