Skip to content

Commit 9e258af

Browse files
committed
cache-common-inc.sh: fix re-download for URLs missing Last-Modified header
Signed-off-by: Norio Nomura <[email protected]>
1 parent 44f2d95 commit 9e258af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hack/cache-common-inc.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ function download_to_cache() {
369369
write_out='{
370370
"http_code":%{http_code},
371371
"last_modified":"%header{Last-Modified}",
372+
"date":"%header{Date}",
372373
"content_type":"%{content_type}",
373374
"url":"%{url_effective}",
374375
"filename":"%{filename_effective}"
@@ -377,7 +378,7 @@ function download_to_cache() {
377378

378379
local code time type url
379380
code=$(jq -r '.http_code' <<<"${curl_info_json}")
380-
time=$(jq -r '.last_modified' <<<"${curl_info_json}")
381+
time=$(jq -r '(.last_modified|select(length>1)) // .date' <<<"${curl_info_json}")
381382
type=$(jq -r '.content_type' <<<"${curl_info_json}")
382383
if [[ ${use_redirected_location} == "YES" ]]; then
383384
url=$(jq -r '.url' <<<"${curl_info_json}")
@@ -400,7 +401,7 @@ function download_to_cache() {
400401
)
401402
local filename
402403
code=$(jq -r '.http_code' <<<"${curl_info_json}")
403-
time=$(jq -r '.last_modified' <<<"${curl_info_json}")
404+
time=$(jq -r '(.last_modified|select(length>1)) // .date' <<<"${curl_info_json}")
404405
type=$(jq -r '.content_type' <<<"${curl_info_json}")
405406
url=$(jq -r '.url' <<<"${curl_info_json}")
406407
filename=$(jq -r '.filename' <<<"${curl_info_json}")

0 commit comments

Comments
 (0)