From: Michael Tremer Date: Fri, 15 Jul 2022 14:12:02 +0000 (+0000) Subject: archive: Return filelist as list of File objects X-Git-Tag: 0.9.28~711 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eee4676dbeabec325985829b8478b035b6b31380;p=pakfire.git archive: Return filelist as list of File objects Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/archive.c b/src/_pakfire/archive.c index b11cb403d..0765a790c 100644 --- a/src/_pakfire/archive.c +++ b/src/_pakfire/archive.c @@ -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);