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:
parent
2684459ed4
commit
0ead624473
25 changed files with 93 additions and 26 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue