mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 12:05:05 +08:00
build: fix file handle leak in GitHub release tool
This is a small patch to remove a defer statement found in a for loop. It instead closes the file after it is done copying the bytes from the tar file reader.
This commit is contained in:
parent
d4b2709fb0
commit
4f7f5404ce
|
@ -374,16 +374,13 @@ func untar(srcFile, fileName, extractDir string) {
|
|||
if err != nil {
|
||||
log.Fatalf("Couldn't open output file: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
err := out.Close()
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't close output: %v", err)
|
||||
}
|
||||
}()
|
||||
n, err := io.Copy(out, tarReader)
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't write output file: %v", err)
|
||||
}
|
||||
if err = out.Close(); err != nil {
|
||||
log.Fatalf("Couldn't close output: %v", err)
|
||||
}
|
||||
log.Printf("Wrote %s (%d bytes) as %q", fileName, n, outPath)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user