mirror of
https://github.com/vbatts/tar-split.git
synced 2024-11-15 04:58:36 +00:00
tar/asm: fix a goroutine deadlock
This commit is contained in:
parent
137c8e61c9
commit
ecf0ed43a1
1 changed files with 6 additions and 2 deletions
|
@ -70,11 +70,13 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp FilePutter) (io.Reader,
|
||||||
pW.CloseWithError(err)
|
pW.CloseWithError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sumChan := make(chan []byte)
|
var csum []byte
|
||||||
if hdr.Size > 0 {
|
if hdr.Size > 0 {
|
||||||
|
sumChan := make(chan []byte)
|
||||||
// if there is a file payload to write, then write the file to the FilePutter
|
// if there is a file payload to write, then write the file to the FilePutter
|
||||||
fileRdr, fileWrtr := io.Pipe()
|
fileRdr, fileWrtr := io.Pipe()
|
||||||
go func() {
|
go func() {
|
||||||
|
defer close(sumChan)
|
||||||
_, csum, err := fp.Put(hdr.Name, fileRdr)
|
_, csum, err := fp.Put(hdr.Name, fileRdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pW.CloseWithError(err)
|
pW.CloseWithError(err)
|
||||||
|
@ -86,13 +88,15 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp FilePutter) (io.Reader,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileWrtr.Close()
|
fileWrtr.Close()
|
||||||
|
csum = <-sumChan
|
||||||
}
|
}
|
||||||
|
|
||||||
// File entries added, regardless of size
|
// File entries added, regardless of size
|
||||||
_, err = p.AddEntry(storage.Entry{
|
_, err = p.AddEntry(storage.Entry{
|
||||||
Type: storage.FileType,
|
Type: storage.FileType,
|
||||||
Name: hdr.Name,
|
Name: hdr.Name,
|
||||||
Size: hdr.Size,
|
Size: hdr.Size,
|
||||||
Payload: <-sumChan,
|
Payload: csum,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pW.CloseWithError(err)
|
pW.CloseWithError(err)
|
||||||
|
|
Loading…
Reference in a new issue