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: c456862f87
This commit is contained in:
Lennart Poettering
2025-09-17 14:35:10 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent ab0ffca130
commit aa7574417b
+25 -5
View File
@@ -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;