tar: fix Go 1.10 breakage
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Mar 7, 2018 at 23:26 UTC
16dad7515b6e5b3d38051422bdb6de5aed0b613d
2 files changed
+27
-6
test/sharness/t0090-get.sh
+20
@@ -125,6 +125,26 @@ test_get_cmd() {
125
test_must_fail ipfs get ../.. 2>actual &&
126
test_cmp expected actual
127
'
128
+
129
+ test_expect_success "create small file" '
130
+ echo "foo" > small &&
131
+ ipfs add -q small > hash_small
132
+ '
133
+
134
+ test_expect_success "get small file" '
135
+ ipfs get -o out_small $(cat hash_small) &&
136
+ test_cmp small out_small
137
+ '
138
+
139
+ test_expect_success "create medium file" '
140
+ head -c 16000 > medium &&
141
+ ipfs add -q medium > hash_medium
142
+ '
143
+
144
+ test_expect_success "get medium file" '
145
+ ipfs get -o out_medium $(cat hash_medium) &&
146
+ test_cmp medium out_medium
147
+ '
148
}
149
150
test_get_fail() {
thirdparty/tar/extractor.go
+7
-6
@@ -114,18 +114,19 @@ func copyWithProgress(to io.Writer, from io.Reader, cb func(int64) int64) error
114
buf := make([]byte, 4096)
115
for {
116
n, err := from.Read(buf)
117
+ if n != 0 {
118
+ cb(int64(n))
119
+ _, err2 := to.Write(buf[:n])
120
+ if err2 != nil {
121
+ return err2
122
+ }
123
+ }
124
if err != nil {
125
if err == io.EOF {
126
return nil
127
}
128
return err
129
}
123
-
124
- cb(int64(n))
125
- _, err = to.Write(buf[:n])
126
- if err != nil {
127
- return err
128
- }
130
}
131
132
}