mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-27 05:17:49 +08:00
unixfs/tar: Fixed reader not properly buffering headers
This commit is contained in:
parent
fe48ae2dd6
commit
16c45a7587
@ -79,6 +79,7 @@ func (i *Reader) writeToBuf(dagnode *mdag.Node, path string, depth int) {
|
||||
i.emitError(err)
|
||||
return
|
||||
}
|
||||
i.flush()
|
||||
|
||||
for _, link := range dagnode.Links {
|
||||
childNode, err := link.GetNode(i.dag)
|
||||
@ -102,6 +103,7 @@ func (i *Reader) writeToBuf(dagnode *mdag.Node, path string, depth int) {
|
||||
i.emitError(err)
|
||||
return
|
||||
}
|
||||
i.flush()
|
||||
|
||||
reader, err := uio.NewDagReader(dagnode, i.dag)
|
||||
if err != nil {
|
||||
@ -150,6 +152,11 @@ func (i *Reader) signal() {
|
||||
i.signalChan <- struct{}{}
|
||||
}
|
||||
|
||||
func (i *Reader) flush() {
|
||||
i.signal()
|
||||
<-i.signalChan
|
||||
}
|
||||
|
||||
func (i *Reader) emitError(err error) {
|
||||
i.err = err
|
||||
i.signal()
|
||||
@ -157,10 +164,6 @@ func (i *Reader) emitError(err error) {
|
||||
|
||||
func (i *Reader) close() {
|
||||
i.closed = true
|
||||
i.flush()
|
||||
}
|
||||
|
||||
func (i *Reader) flush() {
|
||||
defer i.signal()
|
||||
err := i.writer.Close()
|
||||
if err != nil {
|
||||
@ -185,9 +188,7 @@ func (i *Reader) syncCopy(reader io.Reader) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.signal()
|
||||
// wait for Read to finish reading
|
||||
<-i.signalChan
|
||||
i.flush()
|
||||
}
|
||||
if err == io.EOF {
|
||||
break
|
||||
|
||||
Loading…
Reference in New Issue
Block a user