From 3fd01a812a3aa1e735c1ee36b92d524c38cd3b8f Mon Sep 17 00:00:00 2001 From: Mateus Melchiades Date: Fri, 2 Feb 2024 21:22:18 -0300 Subject: [PATCH] fix: Sort partitions when locating disk --- core/disk.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/disk.go b/core/disk.go index 923f9367..3452fc2e 100644 --- a/core/disk.go +++ b/core/disk.go @@ -1,8 +1,10 @@ package albius import ( + "cmp" "encoding/json" "fmt" + "slices" "strconv" "strings" @@ -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 }