0

I'm going to assume that wget starts off with a file filled with zeros and begins filling it with data.

If the download is interrupted, how does wget know where it left off? Looking at the zeros doesn't help because it could very well be part of the data ...

5
  • 6
    "I'm going to assume that wget starts off with a file filled with zeros" Why would you assume that? – muru Jan 27 '20 at 9:32
  • I never considered this issue deeply. The more interesting question is: when it resumes a download, how does wget verify that the part it already has is still valid? The file on the server may have been updated in the meantime, so it has to guard against having a result that joins sections of two different versions. In fact, it also has to guard against the server file being updated during a download -- it may have to restart multiple times. Checksums and Cookies seem appropriate. – Paul_Pedant Jan 27 '20 at 9:45
  • 3
    @Paul_Pedant wget doesn't seem to verify anything when resuming (and probably can't – there's no metadata/progress file, like aria2c has). It seems to behave like curl – try to resume (server dependant) from byte position <size of saved part>, if the requested file is smaller than the saved one it says "there is nothing to do". It's completely possible to "resume" a download with a completely different file and it just gets appended to the existing part, resulting in a partial/corrupt file. – user391836 Jan 27 '20 at 13:26
  • Oh dear. Given that wget can be retrieving a dynamically-constructed file anyway, that is both understandable and worrying. – Paul_Pedant Jan 27 '20 at 16:25
  • @muru oops, i now remember watching the file size expand as wget finishes the download, my bad – A Curious Child Jan 30 '20 at 11:41
2

From man wget:

-c

--continue

Continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program. For instance:

wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z

If there is a file named ls-lR.Z in the current directory, Wget will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.