struct _PakfireStep {
PakfirePool pool;
PakfireTransaction transaction;
+ PakfirePackage package;
Id id;
int nrefs;
};
step->pool = pakfire_transaction_get_pool(transaction);
step->transaction = pakfire_transaction_ref(transaction);
step->id = id;
+
+ // Get the package
+ step->package = pakfire_package_create(step->pool, step->id);
}
return step;
}
static void pakfire_step_free(PakfireStep step) {
+ pakfire_package_unref(step->package);
pakfire_transaction_unref(step->transaction);
pakfire_pool_unref(step->pool);
pakfire_free(step);
}
PAKFIRE_EXPORT PakfirePackage pakfire_step_get_package(PakfireStep step) {
- return pakfire_package_create(step->pool, step->id);
+ return pakfire_package_ref(step->package);
}
PAKFIRE_EXPORT pakfire_step_type_t pakfire_step_get_type(PakfireStep step) {
}
PAKFIRE_EXPORT unsigned long long pakfire_step_get_downloadsize(PakfireStep step) {
- PakfirePackage pkg = NULL;
int downloadsize = 0;
if (pakfire_step_get_downloadtype(step)) {
- pkg = pakfire_step_get_package(step);
- downloadsize = pakfire_package_get_downloadsize(pkg);
+ downloadsize = pakfire_package_get_downloadsize(step->package);
}
- pakfire_package_unref(pkg);
-
return downloadsize;
}
PAKFIRE_EXPORT long pakfire_step_get_installsizechange(PakfireStep step) {
- PakfirePackage pkg = pakfire_step_get_package(step);
- int installsize = pakfire_package_get_installsize(pkg);
+ int installsize = pakfire_package_get_installsize(step->package);
pakfire_step_type_t type = pakfire_step_get_type(step);
switch (type) {
break;
}
- pakfire_package_unref(pkg);
-
return installsize;
}
PAKFIRE_EXPORT int pakfire_step_needs_download(PakfireStep step) {
- PakfirePackage pkg = NULL;
int ret = true;
if (!pakfire_step_get_downloadtype(step))
return false;
- /* Get the package object. */
- pkg = pakfire_step_get_package(step);
-
- PakfireRepo repo = pakfire_package_get_repo(pkg);
+ PakfireRepo repo = pakfire_package_get_repo(step->package);
if (pakfire_repo_is_installed_repo(repo)) {
ret = false;
goto finish;
goto finish;
// Return false if package is in cache.
- ret = !pakfire_cache_has_package(cache, pkg);
+ ret = !pakfire_cache_has_package(cache, step->package);
finish:
- pakfire_package_unref(pkg);
-
return ret;
}
PAKFIRE_EXPORT int pakfire_step_run(PakfireStep step, const pakfire_action_type action) {
pakfire_step_type_t type = pakfire_step_get_type(step);
- // Get the package
- PakfirePackage pkg = pakfire_step_get_package(step);
-
int r = 0;
switch (action) {
// Verify this step
}
END:
- pakfire_package_unref(pkg);
-
return r;
}