Skip to content

Commit

Permalink
Enumerate size properly even if directory is given instead of file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-Roth committed Jul 7, 2019
1 parent 8d06f0d commit e3b754e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/web/lib/fog/fogbase.class.php
Expand Up @@ -2298,9 +2298,18 @@ public static function lasterror()
*
* @return string|int|float
*/
public static function getFilesize($file)
public static function getFilesize($path)
{
$size = filesize($file);
$size = 0;
if (is_dir($path)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file) {
if ($file->getFilename() != ".") {
$size += filesize($file);
}
}
} else {
$size = filesize($path);
}
return is_numeric($size) ? $size : 0;
}
/**
Expand Down

0 comments on commit e3b754e

Please sign in to comment.