diff options
| author | Will Hawkins <[email protected]> | 2022-03-16 20:54:03 -0400 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2022-03-16 20:54:03 -0400 |
| commit | 97f02e6233e8013ef904da7bce9d813c93216c3e (patch) | |
| tree | d85443f7f617e325e9c95b8650544225445992a2 /lbc/lbc.go | |
| parent | eb1d6269aeeeba72185b30273d1cd22b03f17d6e (diff) | |
Bugfix: Stop doing load-inducing downloads before RPM calculation
This fix might be controversial and we will have to confirm it with the
protocol designers: We will stop the actual download of the "large" file
when we are about to start doing the RPM calculation.
Diffstat (limited to 'lbc/lbc.go')
| -rw-r--r-- | lbc/lbc.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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") } |
