From: Michael Tremer Date: Tue, 11 Oct 2022 11:08:24 +0000 (+0000) Subject: package: Compose cache path based on the binary digest X-Git-Tag: 0.9.28~265 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44c222b65fe8e86fdeb0b84a44a6844531c34151;p=pakfire.git package: Compose cache path based on the binary digest Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index ea1acedef..6b2335b51 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -580,12 +580,16 @@ PAKFIRE_EXPORT void pakfire_package_set_maintainer(struct pakfire_package* pkg, static int pakfire_package_make_cache_path(struct pakfire_package* pkg) { const char* filename = pakfire_package_get_filename(pkg); - enum pakfire_digest_types digest; - const char* hexdigest = pakfire_package_get_hexdigest(pkg, &digest); + enum pakfire_digest_types digest_type = PAKFIRE_DIGEST_UNDEFINED; + size_t digest_length = 0; - if (hexdigest && strlen(hexdigest) >= 3) + // Fetch the digest + const unsigned char* digest = pakfire_package_get_digest(pkg, + &digest_type, &digest_length); + + if (digest && digest_length >= 4) return pakfire_cache_path(pkg->pakfire, pkg->path, - "%c%c/%s/%s", hexdigest[0], hexdigest[1], hexdigest + 2, filename); + "%02x/%02x/%02x/%02x/%s", digest[0], digest[1], digest[2], digest[3], filename); return pakfire_cache_path(pkg->pakfire, pkg->path, "%s", filename); }