Skip to content

Commit

Permalink
tar: fix Go 1.10 breakage
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Mar 8, 2018
1 parent b002acc commit 16dad75
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
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 16dad75

Please sign in to comment.