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
92 | 92 | ts.pipeReader.CloseWithError(err) |
93 | 93 | return |
94 | 94 | } |
95 | defer tmpFile.Close() | |
96 | defer os.Remove(tmpFile.Name()) | |
97 | ||
98 | 95 | // Alright, it's either file or directory |
99 | 96 | encodedName, err := Vis(filepath.Base(hdr.Name)) |
100 | 97 | if err != nil { |
174 | 171 | } |
175 | 172 | } |
176 | 173 | populateTree(&root, &e, hdr, ts) |
174 | tmpFile.Close() | |
175 | os.Remove(tmpFile.Name()) | |
177 | 176 | } |
178 | 177 | } |
179 | 178 |