Merge pull request #1313 from JasonYangShadow/issue/1312
fix the failure when updating overlay files existing on different par…
This commit is contained in:
@@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
### Fixed
|
||||
|
||||
- Ensure autobuilt overlays include contextual overlay contents. #1296
|
||||
- Fix the failure when updating overlay files existing on different partitions. #1312
|
||||
|
||||
## v4.5.5, 2024-07-05
|
||||
|
||||
|
||||
@@ -115,10 +115,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// try renaming the tempfile to overlayfile first
|
||||
err := os.Rename(tempFile.Name(), overlayFile)
|
||||
if err != nil {
|
||||
wwlog.Error("Unable to update %s: %s", overlayFile, err)
|
||||
os.Exit(1)
|
||||
// if it fails, which probably means that they exists on different partitions
|
||||
// fallback to data copy
|
||||
wwlog.Debug("Unable to rename temp file: %s to overlay file: %s, try copying the data", tempFile.Name(), overlayFile)
|
||||
cerr := util.CopyFile(tempFile.Name(), overlayFile)
|
||||
if cerr != nil {
|
||||
wwlog.Error("Unable to copy data from temp file: %s to target file: %s, err: %s", tempFile.Name(), overlayFile, err)
|
||||
return cerr
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user