该选项如何--continue/-c
起作用wget
?
如何wget
知道下载是否完成?
答案1
wget
只是简单比较文件大小。
Beginning with Wget 1.7, if you use -c on a file which is of equal size as the one on the server, Wget
will refuse to download the file and print an explanatory message. The same happens when the file is
smaller on the server than locally (presumably because it was changed on the server since your last
download attempt)---because "continuing" is not meaningful, no download occurs.
On the other side of the coin, while using -c, any file that's bigger on the server than locally will be
considered an incomplete download and only "(length(remote) - length(local))" bytes will be downloaded
and tacked onto the end of the local file. This behavior can be desirable in certain cases---for
instance, you can use wget -c to download just the new portion that's been appended to a data collection
or log file.
However, if the file is bigger on the server because it's been changed, as opposed to just appended to,
you'll end up with a garbled file. Wget has no way of verifying that the local file is really a valid
prefix of the remote file. You need to be especially careful of this when using -c in conjunction with
-r, since every file will be considered as an "incomplete download" candidate.
Another instance where you'll get a garbled file if you try to use -c is if you have a lame HTTP proxy
that inserts a "transfer interrupted" string into the local file. In the future a "rollback" option may
be added to deal with this case.
Note that -c only works with FTP servers and with HTTP servers that support the "Range" header.