req icon indicating copy to clipboard operation
req copied to clipboard

ParallelDownload does not close output file after download completed and merged?

Open ZHOUYue67 opened this issue 11 months ago • 0 comments

The *os.File returned by getOutputFile() never seems to get closed in mergeFile(). Is this a bug, or I'm using this the wrong way?

(Windows平台)用了ParallelDownload后立马os.Rename()文件会失败,提示文件正在被使用,我把parallel_download.go单独拿出来改,在mergeFile()里加上等同于defer file.Close()的代码,就可以正确使用了。 虽然os/file_windows.gonewFile()里,存在runtime.SetFinalizer(f.file, (*file).close),但还是建议可控环境下主动调用os.File.Close()

ZHOUYue67 avatar Jan 26 '25 14:01 ZHOUYue67