return r;
}
-static int pakfire_archive_make_filelist_from_json(struct pakfire_archive* archive,
- struct pakfire_filelist** filelist) {
+static int pakfire_archive_import_filelist_from_json(
+ struct pakfire_archive* archive, struct pakfire_package* package) {
struct json_object* array = NULL;
int r;
- struct pakfire_filelist* list = NULL;
- struct pakfire_file* file = NULL;
-
// Fetch the array with the filelist
array = pakfire_archive_metadata_get_object(archive, "filelist", NULL);
if (!array) {
if (!length)
return 0;
- // Create a new filelist object
- r = pakfire_filelist_create(&list, archive->pakfire);
- if (r)
- goto ERROR;
-
// Walk through all items in this array
for (unsigned int i = 0; i < length; i++) {
struct json_object* item = json_object_array_get_idx(array, i);
if (!path)
continue;
- // Create a new file object
- r = pakfire_file_create(&file, archive->pakfire);
+ // Append the file to the package
+ r = pakfire_package_append_file(package, path);
if (r)
- goto ERROR;
-
- // Set path
- r = pakfire_file_set_path(file, path);
- if (r) {
- pakfire_file_unref(file);
- goto ERROR;
- }
-
- // Append the file to the filelist
- r = pakfire_filelist_add(list, file);
- if (r) {
- pakfire_file_unref(file);
- goto ERROR;
- }
-
- // Cleanup
- pakfire_file_unref(file);
+ return r;
}
- // Reference the filelist
- *filelist = pakfire_filelist_ref(list);
-
-ERROR:
- if (list)
- pakfire_filelist_unref(list);
-
- return r;
+ return 0;
}
static int pakfire_archive_make_package_from_json(struct pakfire_archive* archive,
struct pakfire_repo* repo, struct pakfire_package** package) {
struct pakfire_package* pkg = NULL;
- struct pakfire_filelist* filelist = NULL;
int r;
// Calculate digest
}
}
- // Fetch the filelist
- r = pakfire_archive_make_filelist_from_json(archive, &filelist);
+ // Import the filelist
+ r = pakfire_archive_import_filelist_from_json(archive, pkg);
if (r)
goto ERROR;
- // Store the filelist
- if (filelist) {
- r = pakfire_package_set_filelist(pkg, filelist);
- if (r)
- goto ERROR;
- }
-
// Success!
*package = pkg;
r = 0;
ERROR:
- if (filelist)
- pakfire_filelist_unref(filelist);
-
return r;
}