Skip to content

Commit

Permalink
downloader: do atomic renaming of new binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
iameli committed Oct 24, 2023
1 parent ab0de1d commit 6b4a0fe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/downloader/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func ExtractTarGzipArchive(archiveFile, extractPath string, service *types.Servi
if output == "" {
output = filepath.Join(extractPath, path.Base(header.Name))
}
output = output + "-new"
glog.V(9).Infof("extracting to %q", output)
outfile, err := os.Create(output)
if err != nil {
Expand All @@ -176,6 +177,7 @@ func ExtractTarGzipArchive(archiveFile, extractPath string, service *types.Servi
}
outfile.Chmod(fs.FileMode(header.Mode))
outfile.Close()
os.Rename(output, filepath.Join(extractPath, path.Base(header.Name)))
}
}
return nil
Expand Down

0 comments on commit 6b4a0fe

Please sign in to comment.