]> git.ipfire.org Git - pakfire.git/commitdiff
job: Create a directory for the packages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Jun 2025 14:58:38 +0000 (14:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Jun 2025 14:58:38 +0000 (14:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/job.c

index 8fc6ad0728293b9b1243a3a4de858aac5e4322b7..b6a39e9494eef79673ad6472b0d369829e13bafa 100644 (file)
@@ -73,6 +73,9 @@ struct pakfire_job {
                PAKFIRE_JOB_CCACHE     = (1 << 1),
        } flags;
 
+       // Result Directory
+       char resultdir[PATH_MAX];
+
        // Package URL
        char pkg[PATH_MAX];
 
@@ -257,6 +260,9 @@ static void pakfire_job_free(struct pakfire_job* job) {
        if (job->uploads.logfile)
                free(job->uploads.logfile);
 
+       // Cleanup the result directory
+       pakfire_rmtree(job->resultdir, 0);
+
        if (job->client)
                pakfire_client_unref(job->client);
        if (job->config)
@@ -850,6 +856,7 @@ int pakfire_job_stream_logs(struct pakfire_job* self) {
 int pakfire_job_create(struct pakfire_job** job, struct pakfire_ctx* ctx,
                struct pakfire_client* client, struct pakfire_builder* builder, json_object* data) {
        struct pakfire_job* j = NULL;
+       char* p = NULL;
        int r;
 
        // Allocate a new object
@@ -896,6 +903,19 @@ int pakfire_job_create(struct pakfire_job** job, struct pakfire_ctx* ctx,
                goto ERROR;
        }
 
+       // Create a template for the result path
+       r = pakfire_string_set(j->resultdir, PAKFIRE_TMP_DIR "/pakfire-result.XXXXXX");
+       if (r < 0)
+               goto ERROR;
+
+       // Create a place for the result
+       p = pakfire_mkdtemp(j->resultdir);
+       if (!p) {
+               ERROR(j->ctx, "Failed to create a temporary directory: %m\n");
+               r = -errno;
+               goto ERROR;
+       }
+
        // Parse the job
        r = pakfire_parse_job(j, data);
        if (r)