allocate writeFile and backupFile just once

This commit is contained in:
Christian Goll
2025-11-25 09:12:46 +01:00
committed by Jonathon Anderson
parent 983a359c00
commit 0bbab7ac3c
3 changed files with 19 additions and 23 deletions

View File

@@ -49,8 +49,8 @@ func Hostfile() (err error) {
return
}
if writeFile {
err = overlay.CarefulWriteBuffer("/etc/hosts", buffer, backupFile, info.Mode())
if *writeFile {
err = overlay.CarefulWriteBuffer("/etc/hosts", buffer, *backupFile, info.Mode())
if err != nil {
return fmt.Errorf("could not write file from template: %w", err)
}