From a4dc296192fab6391b010191ae825db3665c0bd4 Mon Sep 17 00:00:00 2001 From: Lasith Koswatta Gamage Date: Sat, 16 Dec 2023 11:11:57 +0000 Subject: [PATCH] (feat): Improve labelling code clarity --- internal/layer/label.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/layer/label.go b/internal/layer/label.go index 145cb02..900ff8d 100644 --- a/internal/layer/label.go +++ b/internal/layer/label.go @@ -40,13 +40,14 @@ func (fdl *LabelDeviceLayer) Modify(c *config.Config) ([]action.Action, error) { return nil, fmt.Errorf("🔴 %s: Can not label a device with no file system", bd.Name) } mode := c.GetMode(name) - a, err := fdl.deviceBackend.Label(bd, cd.Label) + // Labelling a device can potentially require unmounting it first + // Therefore, multiple actions may be returned: Label Actions (las) + las, err := fdl.deviceBackend.Label(bd, cd.Label) if err != nil { return nil, err } - for i := range a { - a[i] = a[i].SetMode(mode) - actions = append(actions, a[i]) + for _, la := range las { + actions = append(actions, la.SetMode(mode)) } } return actions, nil