Skip to content

Commit 8629fa9

Browse files
committed
fix: ensure file closed for reading before writing to it
1 parent 7fbb1af commit 8629fa9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ipfs-9-to-10/migration/config_conv.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ func convertFile(path string, enableQuic bool, convBootstrap convArray, convSwar
2727
if err != nil {
2828
return err
2929
}
30-
defer in.Close()
3130

3231
// Create a temp file to write the output to on success
3332
out, err := atomicfile.New(path, 0660)
3433
if err != nil {
34+
in.Close()
3535
return err
3636
}
3737

3838
err = convert(in, out, enableQuic, convBootstrap, convSwarm)
39+
40+
in.Close()
41+
3942
if err != nil {
4043
// There was an error so abort writing the output and clean up temp file
4144
out.Abort()

0 commit comments

Comments
 (0)