]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(sse): don't update uncached files 39152/head
authorRichard Steinmetz <richard@steinmetz.cloud>
Mon, 3 Jul 2023 07:40:46 +0000 (09:40 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Tue, 4 Jul 2023 20:23:47 +0000 (20:23 +0000)
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
lib/private/Files/Storage/Wrapper/Encryption.php

index 4d860e623e0c50f69ee0969f9542b092776cd1d5..43960dfe612ee4ca8bf54e3e9be3aef024ac3609 100644 (file)
@@ -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;