fix(gopher): reject resume when caller supplies Writer
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user