diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2023-07-03 09:40:46 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-07-04 20:23:47 +0000 |
commit | 36b48dea52a35e19941fb52f4a0f6606fbf2eb8e (patch) | |
tree | 2722a3e86f4acfd0dc93d05bce8dcbde0285a78c | |
parent | 3fd03faf58eee0c01a29f8fa8ffcbd4bbd569b21 (diff) | |
download | nextcloud-server-36b48dea52a35e19941fb52f4a0f6606fbf2eb8e.tar.gz nextcloud-server-36b48dea52a35e19941fb52f4a0f6606fbf2eb8e.zip |
fix(sse): don't update uncached files
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encryption.php | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 4d860e623e0..43960dfe612 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 <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 * @@ -141,21 +142,28 @@ class Encryption extends Wrapper { $info = $this->getCache()->get($path); 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; |