tar: fix Go 1.10 breakage

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2018-03-07 23:26:54 +01:00
parent b002acc689
commit 16dad7515b
2 changed files with 27 additions and 6 deletions

View File

@ -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() {

View File

@ -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
}
}
}