Codebase list golang-github-vbatts-go-mtree / 767d4bb
tar: explicitly close files after populateTree Files don't close properly when `defer`ing inside a for loop, since the surrounding function is still iterating in a for loop. To fix this, just close the files explicitly after `populateTree()` in `readHeaders()` Signed-off-by: Stephen Chung <schung@redhat.com> Stephen Chung 7 years ago
1 changed file(s) with 2 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
9292 ts.pipeReader.CloseWithError(err)
9393 return
9494 }
95 defer tmpFile.Close()
96 defer os.Remove(tmpFile.Name())
97
9895 // Alright, it's either file or directory
9996 encodedName, err := Vis(filepath.Base(hdr.Name))
10097 if err != nil {
174171 }
175172 }
176173 populateTree(&root, &e, hdr, ts)
174 tmpFile.Close()
175 os.Remove(tmpFile.Name())
177176 }
178177 }
179178