cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

Please add os.O_TRUNC to writeFlags #23

Closed richardweinberger closed 6 years ago

richardweinberger commented 6 years ago

...otherwise when the target file already exists downloading will with ErrBadLength because the existing file may have a different length.

cavaliercoder commented 6 years ago

This was by design, but I'm happy to rethink it. If the existing file is larger than the remote file, then it can't possibly be the same file. Therefore, grab should exit with a user-actionable error.

I've changed this now, if Request.NoResume is set to true, the local file will always be overwritten, except if the size exactly matches the remote file.