]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
compress: Use common walking routine for extraction
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Sep 2022 19:11:17 +0000 (19:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Sep 2022 19:11:17 +0000 (19:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/compress.c

index 5eca7616065e9475df25a40c7c4974ce9e4aeb44..a8050cdc94b801c120fc78982b060e926628986e 100644 (file)
@@ -662,12 +662,14 @@ static void pakfire_extract_progress(void* p) {
        pakfire_progressbar_update(data->progressbar, position);
 }
 
-static int __pakfire_extract_entry(struct pakfire* pakfire, struct pakfire_extract* data,
-               struct archive_entry* entry) {
+static int __pakfire_extract(struct pakfire* pakfire, struct archive* a,
+               struct archive_entry* entry, void* p) {
        struct pakfire_file* file = NULL;
        char buffer[PATH_MAX];
        int r;
 
+       struct pakfire_extract* data = (struct pakfire_extract*)p;
+
        // Fetch path
        const char* path = archive_entry_pathname(entry);
 
@@ -788,30 +790,10 @@ int pakfire_extract(struct pakfire* pakfire, struct archive* archive,
                pakfire_progressbar_start(data.progressbar, size);
        }
 
-       struct archive_entry* entry = NULL;
-
-       // Walk through the archive
-       while (1) {
-               r = archive_read_next_header(archive, &entry);
-
-               // End when we have reached the end of the archive
-               if (r == ARCHIVE_EOF) {
-                       r = 0;
-                       break;
-               }
-
-               // Raise any other errors
-               else if (r) {
-                       ERROR(pakfire, "Could not read next header: %s\n",
-                               archive_error_string(archive));
-                       goto ERROR;
-               }
-
-               // Extract the entry
-               r = __pakfire_extract_entry(pakfire, &data, entry);
-               if (r)
-                       goto ERROR;
-       }
+       // Walk through the entire archive
+       r = pakfire_walk(pakfire, archive, __pakfire_extract, NULL, &data);
+       if (r)
+               goto ERROR;
 
        // Finish the progressbar
        if (data.progressbar)