Skip to content

Commit

Permalink
fix: Sort partitions when locating disk
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Feb 3, 2024
1 parent 9e421b3 commit 3fd01a8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/disk.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package albius

import (
"cmp"
"encoding/json"
"fmt"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -89,6 +91,11 @@ func LocateDisk(diskname string) (*Disk, error) {
decoded.Disk.Partitions[i].FillPath(decoded.Disk.Path)
}

// Partitions may be unordered
slices.SortFunc(decoded.Disk.Partitions, func(a, b Partition) int {
return cmp.Compare(a.Number, b.Number)
})

return &decoded.Disk, nil
}

Expand Down

0 comments on commit 3fd01a8

Please sign in to comment.