]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Make reading archives more verbose
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 13:52:48 +0000 (13:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 13:52:48 +0000 (13:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c
src/libpakfire/compress.c
src/libpakfire/include/pakfire/compress.h

index 1bc9776bbb1d2738626bda9aae599779a4cc54ee..df747cc8022aa0208168abacbb92b911712589f6 100644 (file)
@@ -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;
 
index f243520ec78c0cf8a7715c8f58f5ca213cef66a5..ae84c24378bc1f89bdce3950759adef2cf543f44 100644 (file)
@@ -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;
                        }
                }
index ca8239e44d3a9c2e62d5e62b39d7d279eba5a060..3ed1bc2a34537bfd50a13cf1c7c3d1cad2a0c8ff 100644 (file)
@@ -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,