]> git.ipfire.org Git - pakfire.git/commitdiff
linter: Create a filelist with all files with issues
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 10:20:38 +0000 (10:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 10:20:38 +0000 (10:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/linter.c

index d1dbc78ba18b1960cfe866ba44b8103567908ea8..0e9cac5ec8abeba9b819f86db6c1f7d915009b1c 100644 (file)
@@ -31,6 +31,7 @@
 #include <pakfire/archive.h>
 #include <pakfire/fhs.h>
 #include <pakfire/file.h>
+#include <pakfire/filelist.h>
 #include <pakfire/linter.h>
 #include <pakfire/linter-file.h>
 #include <pakfire/logging.h>
@@ -64,6 +65,9 @@ struct pakfire_linter {
        // Package
        struct pakfire_package* pkg;
 
+       // Filelist
+       struct pakfire_filelist* filelist;
+
        // Results
        TAILQ_HEAD(results, pakfire_linter_result) results;
 
@@ -121,9 +125,15 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi
                return -errno;
 
        // Store file
-       if (file)
+       if (file) {
                result->file = pakfire_file_ref(file);
 
+               // Add the file to the filelist
+               r = pakfire_filelist_add(linter->filelist, file);
+               if (r < 0)
+                       goto ERROR;
+       }
+
        // Store priority
        result->priority = priority;
 
@@ -133,10 +143,8 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi
        va_end(args);
 
        // Fail on error
-       if (r < 0) {
-               pakfire_linter_result_free(result);
-               return r;
-       }
+       if (r < 0)
+               goto ERROR;
 
        // Store the result
        TAILQ_INSERT_TAIL(&linter->results, result, nodes);
@@ -152,6 +160,12 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi
        }
 
        return 0;
+
+ERROR:
+       if (result)
+               pakfire_linter_result_free(result);
+
+       return r;
 }
 
 int pakfire_linter_create(struct pakfire_linter** linter,
@@ -190,6 +204,11 @@ int pakfire_linter_create(struct pakfire_linter** linter,
                goto ERROR;
        }
 
+       // Create a filelist
+       r = pakfire_filelist_create(&l->filelist, l->pakfire);
+       if (r < 0)
+               goto ERROR;
+
        // Return the pointer
        *linter = pakfire_linter_ref(l);
 
@@ -213,6 +232,8 @@ static void pakfire_linter_free(struct pakfire_linter* linter) {
                pakfire_linter_result_free(result);
        }
 
+       if (linter->filelist)
+               pakfire_filelist_unref(linter->filelist);
        if (linter->archive)
                pakfire_archive_unref(linter->archive);
        if (linter->pkg)