From 27aabdceba362804320ad5c7a5ee27e3e20d8b67 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sun, 12 Dec 2021 17:46:50 -0800 Subject: [PATCH] Make paths absolute for firmware upgrades --- cmd/itctl/firmware/upgrade.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/itctl/firmware/upgrade.go b/cmd/itctl/firmware/upgrade.go index 37489e5..da0101c 100644 --- a/cmd/itctl/firmware/upgrade.go +++ b/cmd/itctl/firmware/upgrade.go @@ -20,6 +20,7 @@ package firmware import ( "fmt" + "path/filepath" "time" "github.com/cheggaaa/pb/v3" @@ -62,7 +63,7 @@ var upgradeCmd = &cobra.Command{ return } - progress, err := client.FirmwareUpgrade(upgType, files...) + progress, err := client.FirmwareUpgrade(upgType, abs(files)...) if err != nil { log.Fatal().Err(err).Msg("Error initiating DFU") } @@ -90,6 +91,17 @@ var upgradeCmd = &cobra.Command{ }, } +func abs(paths []string) []string { + for index, path := range paths { + newPath, err := filepath.Abs(path) + if err != nil { + continue + } + paths[index] = newPath + } + return paths +} + func init() { firmwareCmd.AddCommand(upgradeCmd)