fix(gopher): reject resume when caller supplies Writer

This commit is contained in:
2026-06-30 11:07:46 +02:00
parent dd46aa10f3
commit 535496e6e1
2 changed files with 60 additions and 0 deletions
+10
View File
@@ -165,6 +165,16 @@ func (p *Protocol) downloadText(ctx context.Context, reader *bufio.Reader, req *
// fresh downloads (create) and resume (append). When req.Writer is
// set (caller manages the file), we use it as-is.
if req.Output != "" && req.Output != "-" {
// Resume is meaningful only when we own the output file. If the
// caller already supplied a Writer we cannot append to Output
// behind their back, so disable resume to keep the partial-state
// sidecar consistent with what actually lands on disk.
if req.Resume && req.Writer != nil && req.Verbose {
fmt.Fprintf(os.Stderr, "[gopher] warning: --resume ignored because a Writer is set; output goes to the Writer only\n")
}
if req.Resume && req.Writer != nil {
req.Resume = false
}
if req.Resume {
canResume, resumeMeta, rerr := output.CanResume(req.Output, req.URL.String())
if rerr != nil {