]> git.ipfire.org Git - pakfire.git/commitdiff
repos: Some minor code cleanup when writing metadata
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 2 Feb 2025 14:57:00 +0000 (14:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 2 Feb 2025 14:57:00 +0000 (14:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/repo.c

index 9dab5588244a46ecfef22fadac46e952f4d58891..53199aa8b6e8343a720bc6240b614e8961483635 100644 (file)
@@ -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) {