1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 18:30:08 +00:00

fix(status): prefer internal disks over external in disk listing

When multiple disks are connected, the status command was sorting
only by size, causing external disks to appear first when they are
larger than the internal disk. This resulted in showing incorrect
free space (external disk size) instead of the internal disk.

The sort now prioritizes internal disks before sorting by size,
ensuring the internal disk always appears first.

Fixes #466
This commit is contained in:
tw93
2026-02-16 19:08:25 +08:00
parent 8e8059b0aa
commit 9de661b5df

View File

@@ -82,6 +82,11 @@ func collectDisks() ([]DiskStatus, error) {
annotateDiskTypes(disks) annotateDiskTypes(disks)
sort.Slice(disks, func(i, j int) bool { sort.Slice(disks, func(i, j int) bool {
// First, prefer internal disks over external
if disks[i].External != disks[j].External {
return !disks[i].External
}
// Then sort by size (largest first)
return disks[i].Total > disks[j].Total return disks[i].Total > disks[j].Total
}) })