]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
archive: Allow creating a package without returning it
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 17:37:01 +0000 (17:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 17:37:01 +0000 (17:37 +0000)
This is useful when we simply want to add the package to a repository.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/archive.c

index 8a6438127dc9e493bf5cbb0086da9eaa287cc792..07120fef6944578fba184022ab0a205781c7fb41 100644 (file)
@@ -1762,11 +1762,17 @@ static int pakfire_archive_make_package_from_json(struct pakfire_archive* archiv
        if (r)
                goto ERROR;
 
+       // Return the package (if requested)
+       if (package)
+               *package = pakfire_package_ref(pkg);
+
        // Success!
-       *package = pkg;
        r = 0;
 
 ERROR:
+       if (pkg)
+               pakfire_package_unref(pkg);
+
        return r;
 }
 
@@ -1778,10 +1784,6 @@ int pakfire_archive_make_package(struct pakfire_archive* archive,
        struct pakfire_repo* dummy = NULL;
        int r;
 
-       // Check inputs
-       if (!package)
-               return -EINVAL;
-
        // Use dummy repo if no repository was passed
        if (!repo) {
                dummy = pakfire_get_repo(archive->pakfire, PAKFIRE_REPO_DUMMY);