From: Michael Tremer Date: Wed, 8 Mar 2023 11:48:18 +0000 (+0000) Subject: repo: Compress the SOLV database using Zstandard X-Git-Tag: 0.9.29~352 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f37b04c5e5e46d538da909f0a3824b767cfd8b04;p=pakfire.git repo: Compress the SOLV database using Zstandard Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index 92924e811..ee4a84c54 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -990,9 +990,12 @@ ERROR: } PAKFIRE_EXPORT int pakfire_repo_read_solv(struct pakfire_repo* repo, FILE *f, int flags) { + // Automatically detect compression f = pakfire_xfopen(f, "r"); - if (!f) + if (!f) { + errno = ENOTSUP; return 1; + } int ret = repo_add_solv(repo->repo, f, flags); switch (ret) { @@ -1339,6 +1342,13 @@ static int pakfire_repo_write_database(struct pakfire_repo* repo, const char* pa return 1; } + // Initialize the output being compressed + f = pakfire_zstdfopen(f, "w"); + if (!f) { + ERROR(repo->pakfire, "Could not initialize compression: %m\n"); + return 1; + } + // Write the SOLV database to the temporary file r = pakfire_repo_write_solv(repo, f, 0); if (r) { @@ -1351,7 +1361,7 @@ static int pakfire_repo_write_database(struct pakfire_repo* repo, const char* pa f = NULL; // Create a filename for the database file - r = __pakfire_strftime_now(filename, length, "%Y-%m-%d-%H%M.%s.solv"); + r = __pakfire_strftime_now(filename, length, "%Y-%m-%d-%H%M.%s.solv.zst"); if (r) { ERROR(repo->pakfire, "Could not format database filename: %m\n"); goto ERROR;