Skip to content

Commit 6b4a0fe

Browse files
committed
downloader: do atomic renaming of new binaries
1 parent ab0de1d commit 6b4a0fe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmd/downloader/downloader/downloader.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func ExtractTarGzipArchive(archiveFile, extractPath string, service *types.Servi
163163
if output == "" {
164164
output = filepath.Join(extractPath, path.Base(header.Name))
165165
}
166+
output = output + "-new"
166167
glog.V(9).Infof("extracting to %q", output)
167168
outfile, err := os.Create(output)
168169
if err != nil {
@@ -176,6 +177,7 @@ func ExtractTarGzipArchive(archiveFile, extractPath string, service *types.Servi
176177
}
177178
outfile.Chmod(fs.FileMode(header.Mode))
178179
outfile.Close()
180+
os.Rename(output, filepath.Join(extractPath, path.Base(header.Name)))
179181
}
180182
}
181183
return nil

0 commit comments

Comments
 (0)