mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
fix: show disk usage for the mount being browsed (#1347)
This commit is contained in:
1 parent
e3eada899c
commit
da588f8fa1
3 files changed
+56
-3
No files matched your search
@@ -27,7 +27,7 @@ import {
|
||||
removeFolderShortcut,
|
||||
} from "./api/file-manager-data-api";
|
||||
import { listSSHFiles } from "./api/ssh-file-operations-api";
|
||||
import type { DiskFilesystem } from "./disk-info";
|
||||
import { mountForPath, type DiskFilesystem } from "./disk-info";
|
||||
import { toast } from "sonner";
|
||||
import FolderTree from "./components/FolderTree";
|
||||
import {
|
||||
@@ -702,11 +702,13 @@ export function FileManagerSidebar({
|
||||
// ─── Render ───────────────────────────────────────────────────────────────────
|
||||
|
||||
const storageFilesystems = diskInfo?.filesystems ?? [];
|
||||
const activeStorageMount = selectedMount ?? diskInfo?.mount ?? null;
|
||||
const pathFs = mountForPath(storageFilesystems, currentPath);
|
||||
const activeStorageMount =
|
||||
selectedMount ?? pathFs?.mount ?? diskInfo?.mount ?? null;
|
||||
const selectedFs =
|
||||
selectedMount !== null
|
||||
? (storageFilesystems.find((fs) => fs.mount === selectedMount) ?? null)
|
||||
: null;
|
||||
: pathFs;
|
||||
|
||||
const storage =
|
||||
selectedFs && selectedFs.percent !== null
|
||||
|
||||
@@ -20,3 +20,19 @@ export interface HostDiskInfo {
|
||||
mount: string | null;
|
||||
filesystems?: DiskFilesystem[];
|
||||
}
|
||||
|
||||
/** The filesystem the path lives on: the longest mount point that holds it. */
|
||||
export function mountForPath(
|
||||
filesystems: DiskFilesystem[],
|
||||
path: string | null | undefined,
|
||||
): DiskFilesystem | null {
|
||||
if (!path) return null;
|
||||
let best: DiskFilesystem | null = null;
|
||||
for (const fs of filesystems) {
|
||||
const mount = fs.mount.replace(/\/+$/, "") || "/";
|
||||
const inside =
|
||||
mount === "/" || path === mount || path.startsWith(`${mount}/`);
|
||||
if (inside && (!best || mount.length > best.mount.length)) best = fs;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
Reference in new issue
Block a user