1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

add defer file.Close to avoid potential fd leak

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-06-25 11:57:21 +08:00
parent 2684459ed4
commit 0ead624473
25 changed files with 93 additions and 26 deletions

View file

@ -741,18 +741,20 @@ func TestTarStreamVerification(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer src.Close()
dst, err := os.Create(filepath.Join(tmpdir, id2.Algorithm().String(), id2.Hex(), "tar-split.json.gz"))
if err != nil {
t.Fatal(err)
}
defer dst.Close()
if _, err := io.Copy(dst, src); err != nil {
t.Fatal(err)
}
src.Close()
dst.Close()
src.Sync()
dst.Sync()
ts, err := layer2.TarStream()
if err != nil {