From 59ddd308d59508682409ae61785463e49a8ee92f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 2 Feb 2025 14:57:00 +0000 Subject: [PATCH] repos: Some minor code cleanup when writing metadata Signed-off-by: Michael Tremer --- src/pakfire/repo.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index 9dab5588..53199aa8 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -2047,9 +2047,9 @@ ERROR: return r; } -static int pakfire_repo_write_database(struct pakfire_repo* self, - struct json_object* repomd, char* filename, size_t length) { - char database[PATH_MAX]; +static int pakfire_repo_write_database(struct pakfire_repo* self, struct json_object* repomd) { + char filename[PATH_MAX]; + char path[PATH_MAX]; char tmp[PATH_MAX]; int r; @@ -2084,29 +2084,29 @@ static int pakfire_repo_write_database(struct pakfire_repo* self, f = NULL; // Create a filename for the database file - r = __pakfire_strftime_now(filename, length, "%Y-%m-%d-%H%M.%s.solv.zst"); + r = pakfire_strftime_now(filename, "%Y-%m-%d-%H%M.%s.solv.zst"); if (r) { ERROR(self->ctx, "Could not format database filename: %m\n"); goto ERROR; } // Make final database path - r = pakfire_repo_path(self, database, "repodata/%s", filename); + r = pakfire_repo_path(self, path, "repodata/%s", filename); if (r < 0) { ERROR(self->ctx, "Could not join database path: %m\n"); goto ERROR; } // Link database to its destination - r = link(tmp, database); + r = link(tmp, path); if (r < 0) { - ERROR(self->ctx, "Could not link database %s: %m\n", database); + ERROR(self->ctx, "Could not link database %s: %m\n", path); r = -errno; goto ERROR; } // Add the database to the filelist - r = pakfire_repo_metadata_add_file(self, repomd, database); + r = pakfire_repo_metadata_add_file(self, repomd, path); if (r < 0) goto ERROR; @@ -2147,7 +2147,6 @@ int pakfire_repo_write_metadata(struct pakfire_repo* self, struct pakfire_key* k struct json_object* repomd = NULL; char repomd_path[PATH_MAX]; char sigpath[PATH_MAX]; - char database[PATH_MAX]; FILE* f = NULL; FILE* s = NULL; int r = 1; @@ -2180,12 +2179,10 @@ int pakfire_repo_write_metadata(struct pakfire_repo* self, struct pakfire_key* k goto ERROR; // Write the database - r = pakfire_repo_write_database(self, repomd, database, sizeof(database)); + r = pakfire_repo_write_database(self, repomd); if (r < 0) goto ERROR; - // XXX database hash is missing - // Open repomd.json for writing f = fopen(repomd_path, "w+"); if (!f) { -- 2.39.5