File tree Expand file tree Collapse file tree
lib/private/Files/Storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,11 +97,15 @@ public function is_file(string $path): bool {
9797 }
9898
9999 public function filesize (string $ path ): int |float |false {
100- if ($ this ->is_dir ($ path )) {
101- return 0 ; //by definition
100+ $ type = $ this ->filetype ($ path );
101+ if ($ type === false ) {
102+ return false ;
103+ }
104+ if ($ type !== 'file ' ) {
105+ return 0 ;
102106 } else {
103107 $ stat = $ this ->stat ($ path );
104- return isset ( $ stat ['size ' ]) ? $ stat [ ' size ' ] : 0 ;
108+ return $ stat ['size ' ] ?? 0 ;
105109 }
106110 }
107111
Original file line number Diff line number Diff line change @@ -218,15 +218,19 @@ public function getMetaData(string $path): ?array {
218218 }
219219
220220 public function filetype (string $ path ): string |false {
221- $ filetype = filetype ($ this ->getSourcePath ($ path ));
221+ $ filetype = @ filetype ($ this ->getSourcePath ($ path ));
222222 if ($ filetype === 'link ' ) {
223223 $ filetype = filetype (realpath ($ this ->getSourcePath ($ path )));
224224 }
225225 return $ filetype ;
226226 }
227227
228228 public function filesize (string $ path ): int |float |false {
229- if (!$ this ->is_file ($ path )) {
229+ $ type = $ this ->filetype ($ path );
230+ if ($ type === false ) {
231+ return false ;
232+ }
233+ if ($ type !== 'file ' ) {
230234 return 0 ;
231235 }
232236 $ fullPath = $ this ->getSourcePath ($ path );
You can’t perform that action at this time.
0 commit comments