]> git.ipfire.org Git - pakfire.git/commitdiff
transaction: Use the new check to find available packages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Jan 2025 17:07:23 +0000 (17:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Jan 2025 17:07:23 +0000 (17:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/transaction.c

index e7e9d0f798f1ec14ec3e5c169986854a7cb56913..380f8720e87dfdcd25b393ef7690b88a19641462 100644 (file)
@@ -1925,8 +1925,7 @@ ERROR:
 
 static int pakfire_transaction_package_needs_download(
                struct pakfire_transaction* transaction, struct pakfire_package* pkg) {
-       struct pakfire_repo* repo = NULL;
-       int r = 0;
+       int r;
 
        enum pakfire_steps type = pakfire_transaction_get_step_type(transaction, pkg);
        switch (type) {
@@ -1938,37 +1937,30 @@ static int pakfire_transaction_package_needs_download(
 
                // No need to download for these steps
                default:
-                       goto END;
+                       return 0;
        }
 
        // No download required if this package is already installed
        if (pakfire_package_is_installed(pkg))
-               goto END;
-
-       // Fetch the repository
-       repo = pakfire_package_get_repo(pkg);
-       if (repo) {
-               // We don't need to download for local repositories
-               if (pakfire_repo_is_local(repo))
-                       goto END;
-       }
-
-       // Otherwise we check if the archive is already cached
-       const char* path = pakfire_package_get_string(pkg, PAKFIRE_PKG_CACHE_PATH);
-
-       // Does the file exist?
-       r = access(path, R_OK);
-       if (r == 0)
-               goto END;
+               return 0;
 
-       // This package needs to be downloaded
-       r = 1;
+       // Check if the package is available
+       r = pakfire_package_is_available(pkg);
+       switch (r) {
+               // The package is not available
+               case 0:
+                       // Needs download
+                       return 1;
 
-END:
-       if (repo)
-               pakfire_repo_unref(repo);
+               // The package is available
+               case 1:
+                       // No download needed
+                       return 0;
 
-       return r;
+               // Error
+               default:
+                       return r;
+       }
 }
 
 int pakfire_transaction_download(struct pakfire_transaction* transaction) {