File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -331,7 +331,9 @@ function download_file {
331331 echo " Cache hit for URL: $url " >> " $DIR /install.log"
332332 else
333333 echo " Downloading file to cache: $url " >> " $DIR /install.log"
334- _download_file " $1 " > " $DOWNLOAD_CACHE /$cached_filename " 2>> " $DIR /install.log"
334+ # download to a tmpfile first, so that we don't leave borked cache entries for later runs
335+ _download_file " $1 " > " $DOWNLOAD_CACHE /.temp" 2>> " $DIR /install.log"
336+ mv " $DOWNLOAD_CACHE /.temp" " $DOWNLOAD_CACHE /$cached_filename " >> " $DIR /install.log" 2>&1
335337 fi
336338 cat " $DOWNLOAD_CACHE /$cached_filename " 2>> " $DIR /install.log"
337339 else
Original file line number Diff line number Diff line change @@ -227,7 +227,9 @@ function download-file {
227227 echo " Cache hit for URL: $url " >> $log_file
228228 } else {
229229 echo " Downloading file from $url to $cached_path " >> $log_file
230- Invoke-WebRequest - Uri $url - OutFile $cached_path >> $log_file 2>&1
230+ # download to a tmpfile first, so that we don't leave borked cache entries for later runs
231+ Invoke-WebRequest - Uri $url - OutFile " $download_cache /.temp" >> $log_file 2>&1
232+ Move-Item " $download_cache /.temp" $cached_path >> $log_file 2>&1
231233 }
232234 if (! (Test-Path $cached_path )) {
233235 pm- fatal- error " Failed to download file from $url "
You can’t perform that action at this time.
0 commit comments