From 09983d96d4fe9b6cfd22271b35987d3df5ec7e03 Mon Sep 17 00:00:00 2001 From: Thayol Date: Sat, 22 Aug 2026 15:52:19 +0200 Subject: [PATCH] Add multi-path support --- config.php.example | 7 +++++-- index.php | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config.php.example b/config.php.example index 0a66d9a..0d13cb6 100644 --- a/config.php.example +++ b/config.php.example @@ -15,8 +15,11 @@ $disks = [ "path" => "/opt", "color" => "cornflowerblue", ], - "User Pictures" => [ - "path" => "/home/myuser/pics", + "Pictures" => [ + "path" => [ + "/home/myuser/pics", + "/srv/Pictures", + ], "color" => "peachpuff", ], ], diff --git a/index.php b/index.php index 6ffa2c8..ca32ef5 100644 --- a/index.php +++ b/index.php @@ -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"]; }