Skip to content

Commit

Permalink
Fix slow ISO builds and call Sync on files to be extra safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostman committed Dec 17, 2024
1 parent de5d54b commit 1eadf08
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/fab/recipe/control_build_usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func diskFSCopyFile(dstPath string, srcPath string, destination filesystem.FileS
if dstPath == "/" {
dstPath = filepath.Join("/", filepath.Base(srcPath))
}
dest, err := destination.OpenFile(dstPath, os.O_CREATE|os.O_RDWR|os.O_SYNC)
dest, err := destination.OpenFile(dstPath, os.O_CREATE|os.O_RDWR|os.O_TRUNC)
if err != nil {
return fmt.Errorf("opening dest %q: %w", dstPath, err)
}
Expand All @@ -306,5 +306,11 @@ func diskFSCopyFile(dstPath string, srcPath string, destination filesystem.FileS
return fmt.Errorf("copying: %w", err)
}

if f, ok := dest.(*os.File); ok {
if err := f.Sync(); err != nil {
return fmt.Errorf("syncing dest: %w", err)
}
}

return nil
}

0 comments on commit 1eadf08

Please sign in to comment.