1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-12-20 04:16:31 +00:00

tar/asm: clean up return on errors

This closure on error message needs returns so that the error message is
bubbled up to the reader.
This commit is contained in:
Vincent Batts 2015-07-21 12:08:57 -04:00
parent d3556a0551
commit 6d59e7bc76

View file

@ -61,6 +61,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
}) })
if err != nil { if err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
break // not return. We need the end of the reader. break // not return. We need the end of the reader.
} }
@ -73,6 +74,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
Payload: tr.RawBytes(), Payload: tr.RawBytes(),
}); err != nil { }); err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
var csum []byte var csum []byte
@ -81,6 +83,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
_, csum, err = fp.Put(hdr.Name, tr) _, csum, err = fp.Put(hdr.Name, tr)
if err != nil { if err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
} }
@ -93,6 +96,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
}) })
if err != nil { if err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
if b := tr.RawBytes(); len(b) > 0 { if b := tr.RawBytes(); len(b) > 0 {
@ -102,6 +106,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
}) })
if err != nil { if err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
} }
} }
@ -111,6 +116,7 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
remainder, err := ioutil.ReadAll(outputRdr) remainder, err := ioutil.ReadAll(outputRdr)
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
pW.CloseWithError(err) pW.CloseWithError(err)
return
} }
_, err = p.AddEntry(storage.Entry{ _, err = p.AddEntry(storage.Entry{
Type: storage.SegmentType, Type: storage.SegmentType,
@ -118,9 +124,9 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io
}) })
if err != nil { if err != nil {
pW.CloseWithError(err) pW.CloseWithError(err)
} else { return
pW.Close()
} }
pW.Close()
}() }()
return pR, nil return pR, nil