]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Only read unencrypted_size when file is actually encrypted 40379/head
authorJulius Härtl <jus@bitgrid.net>
Wed, 14 Jun 2023 12:39:15 +0000 (14:39 +0200)
committerJulius Härtl <jus@bitgrid.net>
Tue, 12 Sep 2023 13:05:16 +0000 (15:05 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/Files/Cache/CacheEntry.php
lib/private/Files/FileInfo.php

index ce9df2823c80e48968e72255851a57450c31b98a..d1a64552fd1774af4a9bf6c95ed6621a97b2ba62 100644 (file)
@@ -134,7 +134,7 @@ class CacheEntry implements ICacheEntry {
        }
 
        public function getUnencryptedSize(): int {
-               if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
+               if ($this->data['encrypted'] && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
                        return $this->data['unencrypted_size'];
                } else {
                        return $this->data['size'] ?? 0;
index b3c4629e2b23c25b8ed748b641f196f550303a54..09a291134854222851033e5916fa413e4c8cd5c8 100644 (file)
@@ -205,7 +205,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
                if ($includeMounts) {
                        $this->updateEntryfromSubMounts();
 
-                       if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
+                       if ($this->isEncrypted() && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
                                return $this->data['unencrypted_size'];
                        } else {
                                return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
@@ -227,7 +227,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
         * @return bool
         */
        public function isEncrypted() {
-               return $this->data['encrypted'];
+               return $this->data['encrypted'] ?? false;
        }
 
        /**