From: Michael Tremer Date: Mon, 5 Sep 2022 13:52:48 +0000 (+0000) Subject: archive: Make reading archives more verbose X-Git-Tag: 0.9.28~330 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=662ff8e83fb8cbe263611ddcff96322153b4b10b;p=pakfire.git archive: Make reading archives more verbose Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 1bc9776bb..df747cc80 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -471,6 +471,8 @@ static int __pakfire_archive_read_metadata(struct pakfire* pakfire, struct archi const char* path = archive_entry_pathname(entry); + DEBUG(pakfire, "Reading metadata file: %s\n", path); + // Load the file into memory r = pakfire_archive_copy_data_to_buffer(archive->pakfire, a, entry, &data, &length); if (r) { @@ -533,39 +535,41 @@ static int __pakfire_archive_filter_metadata(struct pakfire* pakfire, if (archive->format >= 6) { // Anything that starts with "." is a metadata file if (*path == '.') - return ARCHIVE_OK; + return PAKFIRE_WALK_OK; // Otherwise, the payload begins - return ARCHIVE_EOF; + return PAKFIRE_WALK_DONE; // Format >= 1 } else if (archive->format >= 1) { // info if (strcmp(path, "info") == 0) - return ARCHIVE_OK; + return PAKFIRE_WALK_OK; // scriptlets else if (pakfire_string_startswith(path, "scriptlets/")) - return ARCHIVE_OK; + return PAKFIRE_WALK_OK; // Ignore anything else - return ARCHIVE_RETRY; + return PAKFIRE_WALK_SKIP; // The pakfire-format file is part of the metadata } else if (strcmp(path, "pakfire-format") == 0) { - return ARCHIVE_OK; + return PAKFIRE_WALK_OK; } // Unknown file - return 1; + return PAKFIRE_WALK_ERROR; } static int pakfire_archive_read_metadata(struct pakfire_archive* archive) { int r; + DEBUG(archive->pakfire, "Reading archive metadata...\n"); + // Walk through the archive r = pakfire_archive_walk(archive, __pakfire_archive_read_metadata, - __pakfire_archive_filter_metadata, NULL); + __pakfire_archive_filter_metadata, archive); if (r) return r; diff --git a/src/libpakfire/compress.c b/src/libpakfire/compress.c index f243520ec..ae84c2437 100644 --- a/src/libpakfire/compress.c +++ b/src/libpakfire/compress.c @@ -526,6 +526,7 @@ int pakfire_walk(struct pakfire* pakfire, struct archive* archive, pakfire_walk_callback callback, pakfire_walk_filter_callback filter_callback, void* p) { struct archive_entry* entry = NULL; + const char* path = NULL; int r; // Walk through the archive @@ -547,6 +548,10 @@ int pakfire_walk(struct pakfire* pakfire, struct archive* archive, return r; } + path = archive_entry_pathname(entry); + + DEBUG(pakfire, "Walking through %s...\n", path); + // Call the filter callback before we call the actual callback if (filter_callback) { r = filter_callback(pakfire, archive, entry, p); @@ -566,7 +571,7 @@ int pakfire_walk(struct pakfire* pakfire, struct archive* archive, // Raise any other errors default: - DEBUG(pakfire, "Filter callback received an error: %d\n", r); + DEBUG(pakfire, "Filter callback returned an error: %d\n", r); return r; } } diff --git a/src/libpakfire/include/pakfire/compress.h b/src/libpakfire/include/pakfire/compress.h index ca8239e44..3ed1bc2a3 100644 --- a/src/libpakfire/include/pakfire/compress.h +++ b/src/libpakfire/include/pakfire/compress.h @@ -45,6 +45,7 @@ typedef int (*pakfire_walk_filter_callback) enum pakfire_walk_codes { PAKFIRE_WALK_OK = 0, + PAKFIRE_WALK_ERROR = 1, // After this code has been sent, we will not process any further entries PAKFIRE_WALK_DONE = -10,