Archived
Add multi-path support
This commit is contained in:
+5
-2
@@ -15,8 +15,11 @@ $disks = [
|
||||
"path" => "/opt",
|
||||
"color" => "cornflowerblue",
|
||||
],
|
||||
"User Pictures" => [
|
||||
"path" => "/home/myuser/pics",
|
||||
"Pictures" => [
|
||||
"path" => [
|
||||
"/home/myuser/pics",
|
||||
"/srv/Pictures",
|
||||
],
|
||||
"color" => "peachpuff",
|
||||
],
|
||||
],
|
||||
|
||||
@@ -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"];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user