}
static int pakfire_repo_scan_file(struct pakfire_repo* repo, const char* path) {
- DEBUG(repo->pakfire, "Scanning %s...\n", path);
-
struct pakfire_archive* archive = NULL;
struct pakfire_package* package = NULL;
+ int r;
+
+ DEBUG(repo->pakfire, "Scanning %s...\n", path);
// Open archive
- int r = pakfire_archive_open(&archive, repo->pakfire, path);
+ r = pakfire_archive_open(&archive, repo->pakfire, path);
if (r)
- return r;
+ goto ERROR;
// Import package into the repository
r = pakfire_archive_make_package(archive, repo, &package);
+ERROR:
if (package)
pakfire_package_unref(package);
- pakfire_archive_unref(archive);
+ if (archive)
+ pakfire_archive_unref(archive);
return r;
}
PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
+ struct pakfire_filelist* filelist = NULL;
struct pakfire_progressbar* progressbar = NULL;
+ int r;
const char* path = pakfire_repo_get_path(repo);
if (!path) {
return 1;
}
- struct pakfire_filelist* filelist;
- int r = pakfire_filelist_create(&filelist, repo->pakfire);
+ // Create a new filelist
+ r = pakfire_filelist_create(&filelist, repo->pakfire);
if (r)
- return r;
+ goto ERROR;
static const char* includes[] = { "*.pfm", NULL };
// Find all package files
r = pakfire_filelist_scan(filelist, path, includes, NULL);
if (r)
- return r;
+ goto ERROR;
// Fetch how many files have been found
const size_t num_files = pakfire_filelist_size(filelist);
ERROR:
if (progressbar)
pakfire_progressbar_unref(progressbar);
- pakfire_filelist_unref(filelist);
+ if (filelist)
+ pakfire_filelist_unref(filelist);
return r;
}