]> git.ipfire.org Git - pakfire.git/commitdiff
package: Fail if we could not fetch the repository
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Oct 2022 11:52:41 +0000 (11:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Oct 2022 14:46:30 +0000 (14:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/package.c

index 5d53efbdbf1c9ff1e650311a4ff54660ea819f1d..3a78a0fc8f86f4529c51729bbe0986b1927a701e 100644 (file)
@@ -1311,8 +1311,13 @@ ERROR:
 static int pakfire_package_append_file(struct pakfire_package* pkg, const char* path) {
        // Fetch repodata
        struct pakfire_repo* repo = pakfire_package_get_repo(pkg);
+       if (!repo) {
+               ERROR(pkg->pakfire, "Could not find repository for %s: %m\n",
+                       pakfire_package_get_nevra(pkg));
+               return 1;
+       }
+
        Repodata* repodata = pakfire_repo_get_repodata(repo);
-       pakfire_repo_unref(repo);
 
        const char* basename = pakfire_basename(path);
        const char* dirname  = pakfire_dirname(path);
@@ -1326,6 +1331,8 @@ static int pakfire_package_append_file(struct pakfire_package* pkg, const char*
        repodata_add_dirstr(repodata, pkg->id,
                SOLVABLE_FILELIST, did, basename);
 
+       pakfire_repo_unref(repo);
+
        return 0;
 }