Skip to content

Commit

Permalink
Merge pull request #39151 from nextcloud/backport/39115/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(sse): don't update uncached files
  • Loading branch information
blizzz authored Jul 6, 2023
2 parents 1bdbb39 + aaa7b41 commit d2be510
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
* @author Vincent Petry <vincent@nextcloud.com>
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* @license AGPL-3.0
*
Expand Down Expand Up @@ -143,21 +144,28 @@ public function filesize($path): false|int|float {
}
if (isset($this->unencryptedSize[$fullPath])) {
$size = $this->unencryptedSize[$fullPath];
// update file cache
if ($info instanceof ICacheEntry) {
$info['encrypted'] = $info['encryptedVersion'];
} else {
if (!is_array($info)) {
$info = [];

// Update file cache (only if file is already cached).
// Certain files are not cached (e.g. *.part).
if (isset($info['fileid'])) {
if ($info instanceof ICacheEntry) {
$info['encrypted'] = $info['encryptedVersion'];
} else {
/**
* @psalm-suppress RedundantCondition
*/
if (!is_array($info)) {
$info = [];
}
$info['encrypted'] = true;
$info = new CacheEntry($info);
}
$info['encrypted'] = true;
$info = new CacheEntry($info);
}

if ($size !== $info->getUnencryptedSize()) {
$this->getCache()->update($info->getId(), [
'unencrypted_size' => $size
]);
if ($size !== $info->getUnencryptedSize()) {
$this->getCache()->update($info->getId(), [
'unencrypted_size' => $size
]);
}
}

return $size;
Expand Down

0 comments on commit d2be510

Please sign in to comment.