mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix foldersize() recursion (#8930)
previously, it tried to add an array to an integer...
This commit is contained in:
committed by
Neil Lathwood
parent
60a1a02f88
commit
153d23b222
@@ -851,30 +851,30 @@ function getlocations()
|
|||||||
}//end getlocations()
|
}//end getlocations()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the recursive file size and count for a directory
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return array [size, file count]
|
||||||
|
*/
|
||||||
function foldersize($path)
|
function foldersize($path)
|
||||||
{
|
{
|
||||||
$total_size = 0;
|
$total_size = 0;
|
||||||
$files = scandir($path);
|
|
||||||
$total_files = 0;
|
$total_files = 0;
|
||||||
|
|
||||||
foreach ($files as $t) {
|
foreach (glob(rtrim($path, '/').'/*', GLOB_NOSORT) as $item) {
|
||||||
if (is_dir(rtrim($path, '/') . '/' . $t)) {
|
if (is_dir($item)) {
|
||||||
if ($t <> '.' && $t <> '..') {
|
list($folder_size, $file_count) = foldersize($item);
|
||||||
$size = foldersize(rtrim($path, '/') . '/' . $t);
|
$total_size += $folder_size;
|
||||||
$total_size += $size;
|
$total_files += $file_count;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$size = filesize(rtrim($path, '/') . '/' . $t);
|
$total_size += filesize($item);
|
||||||
$total_size += $size;
|
|
||||||
$total_files++;
|
$total_files++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [$total_size, $total_files];
|
||||||
$total_size,
|
}
|
||||||
$total_files,
|
|
||||||
);
|
|
||||||
}//end foldersize()
|
|
||||||
|
|
||||||
|
|
||||||
function generate_ap_link($args, $text = null, $type = null)
|
function generate_ap_link($args, $text = null, $type = null)
|
||||||
|
Reference in New Issue
Block a user