From: Michael Tremer Date: Thu, 1 Sep 2022 19:11:17 +0000 (+0000) Subject: compress: Use common walking routine for extraction X-Git-Tag: 0.9.28~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14eedd8008afb1a1a90bce302eb0ee5bc1531b61;p=pakfire.git compress: Use common walking routine for extraction Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/compress.c b/src/libpakfire/compress.c index 5eca76160..a8050cdc9 100644 --- a/src/libpakfire/compress.c +++ b/src/libpakfire/compress.c @@ -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)