]> git.ipfire.org Git - pakfire.git/commitdiff
client: Remove any left-over uploads when freeing the client
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Jun 2025 11:16:48 +0000 (11:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Jun 2025 11:16:48 +0000 (11:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/client.c

index e4d2c0e9b80d54fbac70efe2ad0cb214ee5462ec..d430102fa205b9fba79f90ada0425c5e19ae94ce 100644 (file)
@@ -241,12 +241,24 @@ static int pakfire_client_init(sd_event_source* event, void* data) {
        return 0;
 }
 
+static void pakfire_client_upload_free(struct pakfire_client_upload* upload);
+
 static void pakfire_client_free(struct pakfire_client* self) {
+       struct pakfire_client_upload* upload = NULL;
+
        if (self->auth.access_timer)
                sd_event_source_unref(self->auth.access_timer);
        if (self->auth.refresh_timer)
                sd_event_source_unref(self->auth.refresh_timer);
 
+       // Free uploads
+       while (!STAILQ_EMPTY(&self->uploads)) {
+               upload = STAILQ_FIRST(&self->uploads);
+
+               // Free the upload
+               pakfire_client_upload_free(upload);
+       }
+
        // Event Loop
        if (self->loop)
                sd_event_unref(self->loop);