return r;
}
+static int pakfire_transaction_package_needs_download(
+ struct pakfire_transaction* transaction, PakfirePackage pkg) {
+ pakfire_step_type_t type = pakfire_transaction_get_step_type(transaction, pkg);
+ switch (type) {
+ case PAKFIRE_STEP_INSTALL:
+ case PAKFIRE_STEP_REINSTALL:
+ case PAKFIRE_STEP_DOWNGRADE:
+ case PAKFIRE_STEP_UPGRADE:
+ break;
+
+ // No need to download for these steps
+ default:
+ return 0;
+ }
+
+ // No download required if this package is already installed
+ if (pakfire_package_is_installed(pkg))
+ return 0;
+
+ const char* path = pakfire_package_get_path(pkg);
+
+ // Does the file exist?
+ int r = access(path, R_OK);
+ if (r == 0)
+ return 0;
+
+ // This package needs to be downloaded
+ return 1;
+}
+
PAKFIRE_EXPORT int pakfire_transaction_download(struct pakfire_transaction* transaction) {
struct pakfire_downloader* downloader;
int r;
for (unsigned int i = 0; i < transaction->num; i++) {
PakfirePackage pkg = transaction->packages[i];
- pakfire_step_type_t type = pakfire_transaction_get_step_type(transaction, pkg);
- switch (type) {
- case PAKFIRE_STEP_INSTALL:
- case PAKFIRE_STEP_REINSTALL:
- case PAKFIRE_STEP_DOWNGRADE:
- case PAKFIRE_STEP_UPGRADE:
- break;
-
- default:
- continue;
- }
+ if (!pakfire_transaction_package_needs_download(transaction, pkg))
+ continue;
// Enqueue download
r = pakfire_transaction_download_package(transaction, downloader, pkg);