return archive;
}
-static int pakfire_package_fetch_filelist(struct pakfire_package* pkg, struct pakfire_filelist* filelist) {
+struct pakfire_package_filelist_search {
+ struct pakfire* pakfire;
+ struct pakfire_filelist* filelist;
+ int r;
+};
+
+static int __pakfire_package_fetch_filelist(void* data, Solvable* s, Repodata* repodata,
+ Repokey* key, struct s_KeyValue* kv) {
+ struct pakfire_package_filelist_search* search = (struct pakfire_package_filelist_search*)data;
+
struct pakfire_file* file = NULL;
- Dataiterator di;
- int r = 0;
+ int r;
- pakfire_package_internalize_repo(pkg);
+ // Skip any results of the wrong type
+ if (key->type != REPOKEY_TYPE_DIRSTRARRAY)
+ return 0;
- Solvable* s = get_solvable(pkg);
+ // Fetch the path
+ const char* path = repodata_dir2str(repodata, kv->id, kv->str);
+ if (!path) {
+ r = 1;
+ goto ERROR;
+ }
- dataiterator_init(&di, s->repo->pool, s->repo, pkg->id,
- SOLVABLE_FILELIST, NULL, SEARCH_FILES | SEARCH_COMPLETE_FILELIST);
+ // Create a new file entry
+ r = pakfire_file_create(&file, search->pakfire);
+ if (r)
+ goto ERROR;
- while (dataiterator_step(&di)) {
- r = pakfire_file_create(&file, pkg->pakfire);
- if (r)
- goto ERROR;
+ // Set path
+ r = pakfire_file_set_path(file, path);
+ if (r)
+ goto ERROR;
- pakfire_file_set_path(file, di.kv.str);
+ // Append the file to the filelist
+ r = pakfire_filelist_append(search->filelist, file);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ // Store the error code
+ search->r = r;
- // Append to filelist
- pakfire_filelist_append(filelist, file);
+ if (file)
pakfire_file_unref(file);
- }
-ERROR:
- dataiterator_free(&di);
+ return r;
+}
+
+static int pakfire_package_fetch_filelist(struct pakfire_package* pkg, struct pakfire_filelist* filelist) {
+ struct pakfire_package_filelist_search search = {
+ .pakfire = pkg->pakfire,
+ .filelist = filelist,
+ .r = 0,
+ };
- // Sort the list
+ pakfire_package_internalize_repo(pkg);
+
+ Solvable* s = get_solvable(pkg);
+
+ Repodata* repodata = repo_last_repodata(s->repo);
+
+ // Search for all files
+ repodata_search(repodata, pkg->id, SOLVABLE_FILELIST, SEARCH_FILES,
+ __pakfire_package_fetch_filelist, &search);
+
+ // Break on any error
+ if (search.r)
+ return search.r;
+
+ // Sort the result
pakfire_filelist_sort(filelist);
- return r;
+ return search.r;
}
PAKFIRE_EXPORT struct pakfire_filelist* pakfire_package_get_filelist(struct pakfire_package* pkg) {
pakfire_repo_unref(repo);
+ // This package has changed
+ pakfire_package_has_changed(pkg);
+
return 0;
}