From: Matt Joiner Date: Tue, 12 Aug 2025 14:32:59 +0000 (+1000) Subject: Try harder to pass useful error on webseed read chunks cancellation X-Git-Tag: v1.59.0~2^2~21 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c76a809919c39e4be19fbcee86244f68b15eac21;p=btrtrc.git Try harder to pass useful error on webseed read chunks cancellation --- diff --git a/webseed/client.go b/webseed/client.go index e9b7cc26..b74abca8 100644 --- a/webseed/client.go +++ b/webseed/client.go @@ -146,7 +146,7 @@ func (ws *Client) StartNewRequest(ctx context.Context, r RequestSpec, debugLogge requestParts = append(requestParts, part) } // Technically what we want to ensure is that all parts exist consecutively. If the file data - // isn't consecutive, then it is piece aligned and we wouoldn't need to be doing multiple + // isn't consecutive, then it is piece aligned and we wouldn't need to be doing multiple // requests. TODO: Assert this. panicif.Zero(len(requestParts)) body, w := io.Pipe() @@ -202,10 +202,10 @@ func (me *Client) recvPartResult(ctx context.Context, w io.Writer, part requestP if part.responseBodyWrapper != nil { body = part.responseBodyWrapper(body) } - // Prevent further accidental use - resp.Body = nil + // We did set resp.Body to nil here, but I'm worried the HTTP machinery might do something + // funny. if ctx.Err() != nil { - return ctx.Err() + return context.Cause(ctx) } switch resp.StatusCode { case http.StatusPartialContent: