fix foldersize() recursion (#8930)

previously, it tried to add an array to an integer...
This commit is contained in:
Tony Murray
2018-07-23 11:54:02 -05:00
committed by Neil Lathwood
parent 60a1a02f88
commit 153d23b222

View File

@@ -851,30 +851,30 @@ function getlocations()
}//end getlocations()
/**
* Get the recursive file size and count for a directory
*
* @param string $path
* @return array [size, file count]
*/
function foldersize($path)
{
$total_size = 0;
$files = scandir($path);
$total_files = 0;
foreach ($files as $t) {
if (is_dir(rtrim($path, '/') . '/' . $t)) {
if ($t <> '.' && $t <> '..') {
$size = foldersize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
}
foreach (glob(rtrim($path, '/').'/*', GLOB_NOSORT) as $item) {
if (is_dir($item)) {
list($folder_size, $file_count) = foldersize($item);
$total_size += $folder_size;
$total_files += $file_count;
} else {
$size = filesize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
$total_size += filesize($item);
$total_files++;
}
}
return array(
$total_size,
$total_files,
);
}//end foldersize()
return [$total_size, $total_files];
}
function generate_ap_link($args, $text = null, $type = null)