From c4eccbb304acb095291ef2417ecdb9cc9c7bef9a Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Mon, 3 Jul 2023 09:40:46 +0200 Subject: [PATCH] fix(sse): don't update uncached files Signed-off-by: Richard Steinmetz --- .../Files/Storage/Wrapper/Encryption.php | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index ab3873a7ec0b5..a27f499a2100f 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -17,6 +17,7 @@ * @author Thomas Müller * @author Tigran Mkrtchyan * @author Vincent Petry + * @author Richard Steinmetz * * @license AGPL-3.0 * @@ -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;