From: Michael Tremer Date: Thu, 30 Jan 2025 17:07:23 +0000 (+0000) Subject: transaction: Use the new check to find available packages X-Git-Tag: 0.9.30~245 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d43472b6d89483adfc1f36b1f28c2834e5ffdc3;p=pakfire.git transaction: Use the new check to find available packages Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/transaction.c b/src/pakfire/transaction.c index e7e9d0f7..380f8720 100644 --- a/src/pakfire/transaction.c +++ b/src/pakfire/transaction.c @@ -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) {