Merge pull request #1684 from anderbubble/upgrade-no-backup

Don't attempt to back-up an output file that doesn't exist during upgrade
This commit is contained in:
Christian Goll
2025-02-03 12:17:57 +01:00
committed by GitHub
3 changed files with 9 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Remove a redundant "Building image" log message after image exec. #1694
- Don't populate NetDevs[].Type or NetDevs[].Netmask during upgrade. #1661
- Prefer parent profile values over child profile values. #1672
- Don't attempt to back-up an output file that doesn't exist during upgrade. #1671
## v4.6.0rc1, 2025-01-29

View File

@@ -54,8 +54,10 @@ func UpgradeNodesConf(cmd *cobra.Command, args []string) error {
fmt.Print(string(upgradedYaml))
return nil
} else {
if err := util.CopyFile(outputPath, outputPath+"-old"); err != nil {
return err
if util.IsFile(outputPath) {
if err := util.CopyFile(outputPath, outputPath+"-old"); err != nil {
return err
}
}
return upgraded.PersistToFile(outputPath)
}

View File

@@ -81,8 +81,10 @@ func UpgradeNodesConf(cmd *cobra.Command, args []string) error {
fmt.Print(string(upgradedYaml))
return nil
} else {
if err := util.CopyFile(outputPath, outputPath+"-old"); err != nil {
return err
if util.IsFile(outputPath) {
if err := util.CopyFile(outputPath, outputPath+"-old"); err != nil {
return err
}
}
return upgraded.PersistToFile(outputPath)
}