]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Return filelist as list of File objects
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Jul 2022 14:12:02 +0000 (14:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Jul 2022 14:12:02 +0000 (14:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c

index b11cb403d6494b4655f73aa7eb2cb365c1bf03d8..0765a790c5dedda5d2586c5434c90446cac6470a 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "archive.h"
 #include "errors.h"
+#include "file.h"
 #include "key.h"
 #include "package.h"
 
@@ -229,28 +230,32 @@ static PyObject* Archive_get_filelist(ArchiveObject* self) {
                if (!file)
                        goto ERROR;
 
-               // Fetch the path
-               const char* path = pakfire_file_get_path(file);
-
-               // Convert path to string
-               PyObject* obj = PyUnicode_FromString(path);
+               // Create a new File object
+               PyObject* obj = new_file(file);
+               if (!obj)
+                       goto ERROR;
 
                // Append the new object to the list
                r = PyList_Append(list, obj);
                Py_DECREF(obj);
 
                // If we could not append to the list, we will break
-               if (r) {
-                       Py_DECREF(list);
-                       list = NULL;
+               if (r)
                        goto ERROR;
-               }
 
                // Free file
                pakfire_file_unref(file);
        }
 
+       goto OUT;
+
 ERROR:
+       if (list) {
+               Py_DECREF(list);
+               list = NULL;
+       }
+
+OUT:
        if (filelist)
                pakfire_filelist_unref(filelist);