Skip to content

Commit c0ef527

Browse files
committed
close file before removing
1 parent d1113d8 commit c0ef527

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

get_file_copy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ func copyReader(dst string, src io.Reader, fmode, umask os.FileMode, fileSizeLim
4747

4848
_, err = io.Copy(dstF, src)
4949
if err != nil {
50-
// Remove the file in case of partial write
50+
// Close & remove the file in case of partial write
51+
_ = dstF.Close()
5152
_ = os.Remove(dst)
5253
return err
5354
}
@@ -84,7 +85,8 @@ func copyFile(ctx context.Context, dst, src string, disableSymlinks bool, fmode,
8485

8586
count, err := Copy(ctx, dstF, srcF)
8687
if err != nil {
87-
// Remove the file in case of partial write
88+
// Close & remove the file in case of partial write
89+
_ = dstF.Close()
8890
_ = os.Remove(dst)
8991
return 0, err
9092
}

0 commit comments

Comments
 (0)