]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix Call to a member function getSize() on bool 32008/head
authorCarl Schwan <carl@carlschwan.eu>
Tue, 19 Apr 2022 08:56:54 +0000 (10:56 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Thu, 12 May 2022 13:11:46 +0000 (15:11 +0200)
getFileInfo might return false, handle this case by ignoring the result

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
lib/private/legacy/OC_Files.php

index 41ac20577b2cfc074fcc5028cfbe0ada52d667dc..02e15fd08d545171b62987c2fabaf760ff849485 100644 (file)
@@ -145,21 +145,26 @@ class OC_Files {
                        }
 
                        self::lockFiles($view, $dir, $files);
+                       $numberOfFiles = 0;
+                       $fileSize = 0;
 
                        /* Calculate filesize and number of files */
                        if ($getType === self::ZIP_FILES) {
                                $fileInfos = [];
-                               $fileSize = 0;
                                foreach ($files as $file) {
                                        $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $file);
-                                       $fileSize += $fileInfo->getSize();
-                                       $fileInfos[] = $fileInfo;
+                                       if ($fileInfo) {
+                                               $fileSize += $fileInfo->getSize();
+                                               $fileInfos[] = $fileInfo;
+                                       }
                                }
                                $numberOfFiles = self::getNumberOfFiles($fileInfos);
                        } elseif ($getType === self::ZIP_DIR) {
                                $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $files);
-                               $fileSize = $fileInfo->getSize();
-                               $numberOfFiles = self::getNumberOfFiles([$fileInfo]);
+                               if ($fileInfo) {
+                                       $fileSize = $fileInfo->getSize();
+                                       $numberOfFiles = self::getNumberOfFiles([$fileInfo]);
+                               }
                        }
 
                        $streamer = new Streamer(\OC::$server->getRequest(), $fileSize, $numberOfFiles);