]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pull-job: add 'description' field to PullJob
authorLennart Poettering <lennart@amutable.com>
Thu, 6 Nov 2025 09:46:07 +0000 (10:46 +0100)
committerLennart Poettering <lennart@amutable.com>
Thu, 19 Feb 2026 14:05:14 +0000 (15:05 +0100)
This is shown in the output in place of the URL if non-NULL. This is
useful for OCI's hash-based URLs, which alone are very opaque to read.

src/import/pull-job.c
src/import/pull-job.h

index ef1da55af043abec2c4157105e428b12146d384d..12bdf4c99402493e7592ea71851a11fdc2290f5d 100644 (file)
@@ -64,10 +64,17 @@ PullJob* pull_job_unref(PullJob *j) {
 
         if (j->free_userdata)
                 j->free_userdata(j->userdata);
+        free(j->description);
 
         return mfree(j);
 }
 
+static const char* pull_job_description(PullJob *j) {
+        assert(j);
+
+        return j->description ?: j->url;
+}
+
 static void pull_job_finish(PullJob *j, int ret) {
         assert(j);
 
@@ -77,7 +84,7 @@ static void pull_job_finish(PullJob *j, int ret) {
         if (ret == 0) {
                 j->state = PULL_JOB_DONE;
                 j->progress_percent = 100;
-                log_info("Download of %s complete.", j->url);
+                log_info("Download of %s complete.", pull_job_description(j));
         } else {
                 j->state = PULL_JOB_FAILED;
                 j->error = ret;
@@ -272,7 +279,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
                                 goto finish;
                         }
 
-                        log_debug("%s of %s is %s.", EVP_MD_CTX_get0_name(j->checksum_ctx), j->url, h);
+                        log_debug("%s of %s is %s.", EVP_MD_CTX_get0_name(j->checksum_ctx), pull_job_description(j), h);
                 }
 
                 if (iovec_is_set(&j->expected_checksum) &&
@@ -336,7 +343,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
                 }
         }
 
-        log_info("Acquired %s.", FORMAT_BYTES(j->written_uncompressed));
+        log_info("Acquired %s for %s.", FORMAT_BYTES(j->written_uncompressed), pull_job_description(j));
 
         r = 0;
 
@@ -619,7 +626,7 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
                                 goto fail;
                         }
 
-                        log_info("Downloading %s for %s.", FORMAT_BYTES(j->content_length), j->url);
+                        log_info("Downloading %s for %s.", FORMAT_BYTES(j->content_length), pull_job_description(j));
                 }
 
                 return sz;
@@ -681,11 +688,11 @@ static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_o
 
                         log_info("Got %u%% of %s. %s left at %s/s.",
                                  percent,
-                                 j->url,
+                                 pull_job_description(j),
                                  FORMAT_TIMESPAN(left, USEC_PER_SEC),
                                  FORMAT_BYTES((uint64_t) ((double) dlnow / ((double) done / (double) USEC_PER_SEC))));
                 } else
-                        log_info("Got %u%% of %s.", percent, j->url);
+                        log_info("Got %u%% of %s.", percent, pull_job_description(j));
 
                 j->progress_percent = percent;
                 j->last_status_usec = n;
index 0805184600325326913241545e8828ef7dda1134..7dd3a4cff7961a7f8518f27d37165d54d830f731 100644 (file)
@@ -38,6 +38,8 @@ typedef struct PullJob {
         void *userdata;
         free_func_t free_userdata;
 
+        char *description;
+
         PullJobFinished on_finished;
         PullJobOpenDisk on_open_disk;
         PullJobHeader on_header;