From: Michael Tremer Date: Mon, 10 Jun 2019 23:54:28 +0000 (+0100) Subject: libpakfire: Move cachiing Archive from Package to Step X-Git-Tag: 0.9.28~1285^2~944 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=641cab187076c200ca30a0ddde8ef35c1708cff9;p=pakfire.git libpakfire: Move cachiing Archive from Package to Step Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index ca0c7f50b..c8242d9e3 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -46,7 +46,6 @@ struct _PakfirePackage { Pakfire pakfire; Id id; PakfireFile filelist; - PakfireArchive archive; int nrefs; }; @@ -91,7 +90,6 @@ static void pakfire_package_free(PakfirePackage pkg) { DEBUG(pkg->pakfire, "Releasing Package at %p\n", pkg); pakfire_unref(pkg->pakfire); - pakfire_archive_unref(pkg->archive); pakfire_package_filelist_remove(pkg); pakfire_free(pkg); } @@ -892,15 +890,13 @@ PAKFIRE_EXPORT char* pakfire_package_get_cache_path(PakfirePackage pkg) { } PAKFIRE_EXPORT PakfireArchive pakfire_package_get_archive(PakfirePackage pkg) { - // Return the package if it has already been opened - if (pkg->archive) - return pakfire_archive_ref(pkg->archive); - // Otherwise open the archive from the cache char* path = pakfire_package_get_cache_path(pkg); - PakfireArchive archive = pakfire_archive_open(pkg->pakfire, path); + if (!path) + return NULL; - // Free resources + // Open archive + PakfireArchive archive = pakfire_archive_open(pkg->pakfire, path); pakfire_free(path); return archive; diff --git a/src/libpakfire/step.c b/src/libpakfire/step.c index e8fc54a83..610dcf3fa 100644 --- a/src/libpakfire/step.c +++ b/src/libpakfire/step.c @@ -38,6 +38,7 @@ struct _PakfireStep { Pakfire pakfire; PakfirePackage package; + PakfireArchive archive; pakfire_step_type_t type; int nrefs; }; @@ -108,6 +109,7 @@ static void pakfire_step_free(PakfireStep step) { DEBUG(step->pakfire, "Releasing Step at %p\n", step); pakfire_package_unref(step->package); + pakfire_archive_unref(step->archive); pakfire_unref(step->pakfire); pakfire_free(step); } @@ -222,8 +224,8 @@ static int pakfire_step_verify(PakfireStep step) { return 1; // Fetch the archive - PakfireArchive archive = pakfire_package_get_archive(step->package); - if (!archive) { + step->archive = pakfire_package_get_archive(step->package); + if (!step->archive) { char* nevra = pakfire_package_get_nevra(step->package); char* cache_path = pakfire_package_get_cache_path(step->package); @@ -237,8 +239,13 @@ static int pakfire_step_verify(PakfireStep step) { } // Verify the archive - pakfire_archive_verify_status_t status = pakfire_archive_verify(archive); - pakfire_archive_unref(archive); + pakfire_archive_verify_status_t status = pakfire_archive_verify(step->archive); + + // Log error + if (status) { + const char* error = pakfire_archive_verify_strerror(status); + ERROR(step->pakfire, "Archive verification failed: %s\n", error); + } return status; }