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) {
// 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) {