Make paths absolute for firmware upgrades

This commit is contained in:
Elara 2021-12-12 17:46:50 -08:00
parent c019d7523b
commit 27aabdceba

View File

@ -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)