Don't attempt to back-up an output file that doesn't exist during upgrade

- Fixes: #1671

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-30 09:30:52 -07:00
committed by Christian Goll
parent ff88afbf6d
commit 8b26088083
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)
}