]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix unencrypted_size for files when scanning
authorRobin Appelman <robin@icewind.nl>
Fri, 3 Mar 2023 16:10:56 +0000 (17:10 +0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 11 Oct 2023 12:41:43 +0000 (14:41 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Cache/Scanner.php
lib/private/Files/Storage/Wrapper/Encryption.php

index 720428e9bd821377639781cc853a2c0a84d90098..228f5d4056e652e1fb417b788a5cd30fa843b48c 100644 (file)
@@ -208,9 +208,17 @@ class Scanner extends BasicEmitter implements IScanner {
                                                                $data['etag'] = $etag;
                                                        }
                                                }
+
+                                               // we only updated unencrypted_size if it's already set
+                                               if ($cacheData['unencrypted_size'] === 0) {
+                                                       unset($data['unencrypted_size']);
+                                               }
+
                                                // Only update metadata that has changed
                                                $newData = array_diff_assoc($data, $cacheData->getData());
                                        } else {
+                                               // we only updated unencrypted_size if it's already set
+                                               unset($data['unencrypted_size']);
                                                $newData = $data;
                                                $fileId = -1;
                                        }
index 2b4abbe917e331afc253a2c20ad20ecb5953950c..8b64697ed94ad7513a9c384b5dc725bef13a52fc 100644 (file)
@@ -188,10 +188,12 @@ class Encryption extends Wrapper {
                if (isset($this->unencryptedSize[$fullPath])) {
                        $data['encrypted'] = true;
                        $data['size'] = $this->unencryptedSize[$fullPath];
+                       $data['unencrypted_size'] = $data['size'];
                } else {
                        if (isset($info['fileid']) && $info['encrypted']) {
                                $data['size'] = $this->verifyUnencryptedSize($path, $info->getUnencryptedSize());
                                $data['encrypted'] = true;
+                               $data['unencrypted_size'] = $data['size'];
                        }
                }
 
@@ -502,7 +504,8 @@ class Encryption extends Wrapper {
                $result = $unencryptedSize;
 
                if ($unencryptedSize < 0 ||
-                       ($size > 0 && $unencryptedSize === $size)
+                       ($size > 0 && $unencryptedSize === $size) ||
+                       $unencryptedSize > $size
                ) {
                        // check if we already calculate the unencrypted size for the
                        // given path to avoid recursions