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;