diff --git a/CHANGELOG.md b/CHANGELOG.md index ce4f6da0..9e00980f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/app/wwctl/overlay/edit/main.go b/internal/app/wwctl/overlay/edit/main.go index 07a41ce2..6979b0b4 100644 --- a/internal/app/wwctl/overlay/edit/main.go +++ b/internal/app/wwctl/overlay/edit/main.go @@ -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