mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-30 14:46:31 +00:00
pkg-download: handle interrupted wget downloads
When a wget download is interrupted, the downloaded file is still created. It will therefore not be re-downloaded in the next build, and the extraction will fail. To avoid this, download to a temporary file first and rename when the download is successful. The existing mechanism doesn't work for interrupted downloads because the whole sub-shell is interrupted, so the rm-part never gets executed. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
This commit is contained in:
parent
9910eba33a
commit
96885ca7eb
@ -158,11 +158,14 @@ endef
|
|||||||
# Download a file using wget. Only download the file if it doesn't
|
# Download a file using wget. Only download the file if it doesn't
|
||||||
# already exist in the download directory. If the download fails,
|
# already exist in the download directory. If the download fails,
|
||||||
# remove the file (because wget -O creates a 0-byte file even if the
|
# remove the file (because wget -O creates a 0-byte file even if the
|
||||||
# download fails).
|
# download fails). To handle an interrupted download as well, download
|
||||||
|
# to a temporary file first. The temporary file will be overwritten
|
||||||
|
# the next time the download is tried.
|
||||||
define DOWNLOAD_WGET
|
define DOWNLOAD_WGET
|
||||||
test -e $(DL_DIR)/$(2) || \
|
test -e $(DL_DIR)/$(2) || \
|
||||||
$(WGET) -O $(DL_DIR)/$(2) '$(call qstrip,$(1))' || \
|
($(WGET) -O $(DL_DIR)/$(2).tmp '$(call qstrip,$(1))' && \
|
||||||
(rm -f $(DL_DIR)/$(2) ; exit 1)
|
mv $(DL_DIR)/$(2).tmp $(DL_DIR)/$(2)) || \
|
||||||
|
(rm -f $(DL_DIR)/$(2).tmp ; exit 1)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define SOURCE_CHECK_WGET
|
define SOURCE_CHECK_WGET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user