Resume interrupted downloads in shell cookbook
Problem:
In the shell cookbook, if a wget transfer fails or is interupted it will not be resumed in subsequent runs. If there is no checksum, execution will continue and the user will be presented with a confusing "This does not look like a tar archive" error:
First time:
cook - jansson fetch
--2023-11-25 03:33:51-- https://www.digip.org/jansson/releases/jansson-2.10.tar.gz
Resolving www.digip.org (www.digip.org)... 91.232.155.81, 2001:67c:1be8:1337::443
Connecting to www.digip.org (www.digip.org)|91.232.155.81|:443... connected.
ERROR: The certificate of 'www.digip.org' is not trusted.
ERROR: The certificate of 'www.digip.org' has expired.
The certificate has expired
make: *** [mk/ci.mk:24: ci-pkg] Error 5
Retry:
cook - jansson fetch
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
make: *** [mk/ci.mk:24: ci-pkg] Error 2
To recover, the user has to delete the corrupted source.tar.
I tried to fix this earlier by adding --continue
in 749fd620. It was a mistake and this alone doesn't change anything for the shell version of the cookbook.
Changes introduced by this pull request:
We first download the file to source.tar.tmp
, trying to resume the download if the file exist. After wget exists successfully we move the temporary file to source.tar
.
This is the equivalent of this bit of cook.rs, but for the shell version of the cookbook.