From aa7574417b86ac0bb7ed492b7cfc872e9ace15d7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 25 Aug 2025 17:05:09 +0200 Subject: [PATCH] pull: fix SHA256SUMS fallback for file:// URLs For file:// there's no http error code 404, but there's CURLE_FILE_COULDNT_READ_FILE hence call ->on_not_found() in that case too. Follow-up for: c456862f87237831ce2bbaeb53a37d1b3d669285 --- src/import/pull-job.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 36b4c9ee182..8025e32888b 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -126,17 +126,37 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) { if (!j || IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED)) return; - if (result != CURLE_OK) { - r = log_error_errno(SYNTHETIC_ERRNO(EIO), "Transfer failed: %s", curl_easy_strerror(result)); - goto finish; - } - code = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); if (code != CURLE_OK || !scheme) { r = log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to retrieve URL scheme."); goto finish; } + if (strcaseeq(scheme, "FILE") && result == CURLE_FILE_COULDNT_READ_FILE && j->on_not_found) { + _cleanup_free_ char *new_url = NULL; + + /* This resource wasn't found, but the implementor wants to maybe let us know a new URL, query for it. */ + r = j->on_not_found(j, &new_url); + if (r < 0) + goto finish; + if (r > 0) { /* A new url to use */ + assert(new_url); + + r = pull_job_restart(j, new_url); + if (r < 0) + goto finish; + + return; + } + + /* if this didn't work, handle like any other error below */ + } + + if (result != CURLE_OK) { + r = log_error_errno(SYNTHETIC_ERRNO(EIO), "Transfer failed: %s", curl_easy_strerror(result)); + goto finish; + } + if (STRCASE_IN_SET(scheme, "HTTP", "HTTPS")) { long status; -- 2.47.3