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 {
331
331
echo " Cache hit for URL: $url " >> " $DIR /install.log"
332
332
else
333
333
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
335
337
fi
336
338
cat " $DOWNLOAD_CACHE /$cached_filename " 2>> " $DIR /install.log"
337
339
else
Original file line number Diff line number Diff line change @@ -227,7 +227,9 @@ function download-file {
227
227
echo " Cache hit for URL: $url " >> $log_file
228
228
} else {
229
229
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
231
233
}
232
234
if (! (Test-Path $cached_path )) {
233
235
pm- fatal- error " Failed to download file from $url "
You can’t perform that action at this time.
0 commit comments