Add multi-path support

This commit is contained in:
2026-08-22 15:52:19 +02:00
parent 4e0a17ef55
commit 09983d96d4
2 changed files with 17 additions and 4 deletions
+5 -2
View File
@@ -15,8 +15,11 @@ $disks = [
"path" => "/opt",
"color" => "cornflowerblue",
],
"User Pictures" => [
"path" => "/home/myuser/pics",
"Pictures" => [
"path" => [
"/home/myuser/pics",
"/srv/Pictures",
],
"color" => "peachpuff",
],
],
+12 -2
View File
@@ -38,11 +38,21 @@ if (!file_exists($stats_file)) {
$stats["storage"][$disk_name]["used_bytes"] = (int) trim(shell_exec('df --block-size=1 --output=used ' . escapeshellarg($disk_stats["mount_point"]) . ' | tail -1'));
$other_used = $stats["storage"][$disk_name]["used_bytes"];
if (!isset($disk_stats["categories"])) {
$stats["storage"][$disk_name]["categories"] = [];
$disk_stats["categories"] = [];
}
foreach ($disk_stats["categories"] as $category_name => $category_stats) {
$stats["storage"][$disk_name]["categories"][$category_name]["bytes"] = (int) shell_exec('du -sb ' . escapeshellarg($stats["storage"][$disk_name]["categories"][$category_name]["path"]) . ' | cut -f1');
$paths = $category_stats["path"];
if (!is_array($category_stats["path"])) {
$paths = [$category_stats["path"]];
}
$stats["storage"][$disk_name]["categories"][$category_name]["bytes"] = 0;
foreach ($paths as $path) {
$bytes = (int) shell_exec('du -sb ' . escapeshellarg($path) . ' | cut -f1');
$stats["storage"][$disk_name]["categories"][$category_name]["bytes"] += $bytes;
}
$other_used -= $stats["storage"][$disk_name]["categories"][$category_name]["bytes"];
}