@@ -109,7 +109,7 @@ public function getNumericStorageId() {
109109 /**
110110 * get the stored metadata of a file or folder
111111 *
112- * @param string | int $file either the path of a file or folder or the file id for a file or folder
112+ * @param string| int $file either the path of a file or folder or the file id for a file or folder
113113 * @return ICacheEntry|false the cache entry as array or false if the file is not found in the cache
114114 */
115115 public function get ($ file ) {
@@ -131,15 +131,17 @@ public function get($file) {
131131 $ data = $ result ->fetch ();
132132 $ result ->closeCursor ();
133133
134- //merge partial data
135- if (!$ data && is_string ($ file ) && isset ($ this ->partial [$ file ])) {
136- return $ this ->partial [$ file ];
137- } elseif (!$ data ) {
138- return $ data ;
139- } else {
134+ if ($ data !== false ) {
140135 $ data ['metadata ' ] = $ metadataQuery ->extractMetadata ($ data )->asArray ();
141136 return self ::cacheEntryFromData ($ data , $ this ->mimetypeLoader );
137+ } else {
138+ //merge partial data
139+ if (is_string ($ file ) && isset ($ this ->partial [$ file ])) {
140+ return $ this ->partial [$ file ];
141+ }
142142 }
143+
144+ return false ;
143145 }
144146
145147 /**
@@ -886,19 +888,23 @@ public function searchQuery(ISearchQuery $query) {
886888 /**
887889 * Re-calculate the folder size and the size of all parent folders
888890 *
889- * @param string|boolean $path
890- * @param array $data (optional) meta data of the folder
891+ * @param array|ICacheEntry|null $data (optional) meta data of the folder
891892 */
892- public function correctFolderSize ($ path , $ data = null , $ isBackgroundScan = false ) {
893+ public function correctFolderSize (string $ path , $ data = null , bool $ isBackgroundScan = false ): void {
893894 $ this ->calculateFolderSize ($ path , $ data );
895+
894896 if ($ path !== '' ) {
895897 $ parent = dirname ($ path );
896898 if ($ parent === '. ' || $ parent === '/ ' ) {
897899 $ parent = '' ;
898900 }
901+
899902 if ($ isBackgroundScan ) {
900903 $ parentData = $ this ->get ($ parent );
901- if ($ parentData ['size ' ] !== -1 && $ this ->getIncompleteChildrenCount ($ parentData ['fileid ' ]) === 0 ) {
904+ if ($ parentData !== false
905+ && $ parentData ['size ' ] !== -1
906+ && $ this ->getIncompleteChildrenCount ($ parentData ['fileid ' ]) === 0
907+ ) {
902908 $ this ->correctFolderSize ($ parent , $ parentData , $ isBackgroundScan );
903909 }
904910 } else {
@@ -1009,8 +1015,8 @@ protected function calculateFolderSizeInner(string $path, $entry = null, bool $i
10091015 }
10101016
10111017 // only set unencrypted size for a folder if any child entries have it set, or the folder is empty
1012- $ shouldWriteUnEncryptedSize = $ unencryptedMax > 0 || $ totalSize === 0 || $ entry ['unencrypted_size ' ] > 0 ;
1013- if ($ entry ['size ' ] !== $ totalSize || ($ entry ['unencrypted_size ' ] !== $ unencryptedTotal && $ shouldWriteUnEncryptedSize )) {
1018+ $ shouldWriteUnEncryptedSize = $ unencryptedMax > 0 || $ totalSize === 0 || ( $ entry ['unencrypted_size ' ] ?? 0 ) > 0 ;
1019+ if ($ entry ['size ' ] !== $ totalSize || (( $ entry ['unencrypted_size ' ] ?? 0 ) !== $ unencryptedTotal && $ shouldWriteUnEncryptedSize )) {
10141020 if ($ shouldWriteUnEncryptedSize ) {
10151021 // if all children have an unencrypted size of 0, just set the folder unencrypted size to 0 instead of summing the sizes
10161022 if ($ unencryptedMax === 0 ) {
0 commit comments