mirror of
https://github.com/vbatts/tar-split.git
synced 2024-12-23 22:06:31 +00:00
tar/asm: don't defer file closing
this `for {}` can read many files. defering the file handle close can cause an EMFILE (too many open files).
This commit is contained in:
parent
86ada47639
commit
e33913bf75
1 changed files with 3 additions and 1 deletions
|
@ -44,10 +44,10 @@ func NewOutputTarStream(fg storage.FileGetter, up storage.Unpacker) io.ReadClose
|
||||||
pw.CloseWithError(err)
|
pw.CloseWithError(err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
defer fh.Close()
|
|
||||||
c := crc64.New(storage.CRCTable)
|
c := crc64.New(storage.CRCTable)
|
||||||
tRdr := io.TeeReader(fh, c)
|
tRdr := io.TeeReader(fh, c)
|
||||||
if _, err := io.Copy(pw, tRdr); err != nil {
|
if _, err := io.Copy(pw, tRdr); err != nil {
|
||||||
|
fh.Close()
|
||||||
pw.CloseWithError(err)
|
pw.CloseWithError(err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,11 @@ func NewOutputTarStream(fg storage.FileGetter, up storage.Unpacker) io.ReadClose
|
||||||
// I would rather this be a comparable ErrInvalidChecksum or such,
|
// I would rather this be a comparable ErrInvalidChecksum or such,
|
||||||
// but since it's coming through the PipeReader, the context of
|
// but since it's coming through the PipeReader, the context of
|
||||||
// _which_ file would be lost...
|
// _which_ file would be lost...
|
||||||
|
fh.Close()
|
||||||
pw.CloseWithError(fmt.Errorf("file integrity checksum failed for %q", entry.Name))
|
pw.CloseWithError(fmt.Errorf("file integrity checksum failed for %q", entry.Name))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
fh.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pw.Close()
|
pw.Close()
|
||||||
|
|
Loading…
Reference in a new issue