Make paths absolute for firmware upgrades

This commit is contained in:
Elara 2021-12-12 17:46:50 -08:00
parent c019d7523b
commit 27aabdceba
1 changed files with 13 additions and 1 deletions

View File

@ -20,6 +20,7 @@ package firmware
import ( import (
"fmt" "fmt"
"path/filepath"
"time" "time"
"github.com/cheggaaa/pb/v3" "github.com/cheggaaa/pb/v3"
@ -62,7 +63,7 @@ var upgradeCmd = &cobra.Command{
return return
} }
progress, err := client.FirmwareUpgrade(upgType, files...) progress, err := client.FirmwareUpgrade(upgType, abs(files)...)
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("Error initiating DFU") 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() { func init() {
firmwareCmd.AddCommand(upgradeCmd) firmwareCmd.AddCommand(upgradeCmd)