summaryrefslogtreecommitdiff
path: root/lbc/lbc.go
diff options
context:
space:
mode:
Diffstat (limited to 'lbc/lbc.go')
-rw-r--r--lbc/lbc.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/lbc/lbc.go b/lbc/lbc.go
index a17d1ee..01b1a4d 100644
--- a/lbc/lbc.go
+++ b/lbc/lbc.go
@@ -105,7 +105,6 @@ func (lbd *LoadBearingConnectionDownload) doDownload(ctx context.Context) {
}
cr := &countingReader{n: &lbd.downloaded, ctx: ctx, readable: get.Body}
_, _ = io.Copy(ioutil.Discard, cr)
- lbd.valid = false
get.Body.Close()
if lbd.debug {
fmt.Printf("Ending a load-bearing download.\n")
@@ -156,10 +155,13 @@ func (s *syntheticCountingReader) Read(p []byte) (n int, err error) {
func (lbu *LoadBearingConnectionUpload) doUpload(ctx context.Context) bool {
lbu.uploaded = 0
s := &syntheticCountingReader{n: &lbu.uploaded, ctx: ctx}
- if resp, err := lbu.client.Post(lbu.Path, "application/octet-stream", s); err == nil {
- resp.Body.Close()
+ var resp *http.Response = nil
+ var err error
+
+ if resp, err = lbu.client.Post(lbu.Path, "application/octet-stream", s); err != nil {
+ lbu.valid = false
}
- lbu.valid = false
+ resp.Body.Close()
if lbu.debug {
fmt.Printf("Ending a load-bearing upload.\n")
}