Skip to content

Commit

Permalink
Merge pull request #4790 from ipfs/fix/tar-eof
Browse files Browse the repository at this point in the history
tar: fix Go 1.10 breakage
  • Loading branch information
whyrusleeping committed Mar 12, 2018
2 parents 5622cc5 + 1b96ad7 commit ba3cd5b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ci/Dockerfile.buildenv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.9
FROM golang:1.10
MAINTAINER Jakub Sztandera <kubuxu@ipfs.io>


Expand Down
20 changes: 20 additions & 0 deletions test/sharness/t0090-get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ test_get_cmd() {
test_must_fail ipfs get ../.. 2>actual &&
test_cmp expected actual
'

test_expect_success "create small file" '
echo "foo" > small &&
ipfs add -q small > hash_small
'

test_expect_success "get small file" '
ipfs get -o out_small $(cat hash_small) &&
test_cmp small out_small
'

test_expect_success "create medium file" '
head -c 16000 > medium &&
ipfs add -q medium > hash_medium
'

test_expect_success "get medium file" '
ipfs get -o out_medium $(cat hash_medium) &&
test_cmp medium out_medium
'
}

test_get_fail() {
Expand Down
13 changes: 7 additions & 6 deletions thirdparty/tar/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@ func copyWithProgress(to io.Writer, from io.Reader, cb func(int64) int64) error
buf := make([]byte, 4096)
for {
n, err := from.Read(buf)
if n != 0 {
cb(int64(n))
_, err2 := to.Write(buf[:n])
if err2 != nil {
return err2
}
}
if err != nil {
if err == io.EOF {
return nil
}
return err
}

cb(int64(n))
_, err = to.Write(buf[:n])
if err != nil {
return err
}
}

}

0 comments on commit ba3cd5b

Please sign in to comment.