Skip to content

BUG: wget2 sometimes deletes partial download if interrupted during download

Description:

Starting a download then hitting Ctrl+C results in the partial file being deleted under certain circumstances.

Details:

  • This happens regardles of -c being specified or not.
  • it happens 100% reliably, but only on specific servers, and not on others.
  • When it does occur, wget2 prints the error message "Unexpected body length <number>" before exiting.
  • The issue occurs on a HTTP/1.1 server that returns always returns 2**31 as the content-length. If the the server terminates the connection after the all the content is sent, the file isn't removed. So even though the server is non-compliant, downloads do work. However, if a the download is interrupted by the user with Ctrl-C. wget2 complains of an error and removes the partial file. length". But the fact is this happens on some server and not others.
  • If a partial file already exists, calling "wget2 -c" successfully resumes the download from this server. Strangely, if the resumed download process is then interrupted, the file is not deleted.

Notes:

  • wget1 doesn't do this, and I think wget1 is right.
  • curl has --remove-on-error, and it too has this off by default.
  • Even if one thinks that the proper response for an unexpected body length is to delete all the data (and I disagree), it's Not clear how an interrupted download would ever NOT result in the same "unexpected body length" error. and yet, this happens with some servers and not others. So I think there's unintended behavior here.

Version: current git 262a8d5b

Thank you for your time, attention, and efforts. 🙏

Update: Issue corrected after I realized #705

Edited by Levi Caspian