From e1a96658d4daf4607e381897b3950feb76e59b2a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 2 Feb 2025 15:00:12 +0000 Subject: [PATCH] repos: Add filesize to metadata Signed-off-by: Michael Tremer --- src/pakfire/repo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index 53199aa8..a5e020a4 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -1975,9 +1975,18 @@ static int pakfire_repo_metadata_add_file(struct pakfire_repo* self, struct json_object* chksums = NULL; char filename[PATH_MAX]; char* hexdigest = NULL; + struct stat st = {}; int digest; int r; + // Stat the file + r = stat(path, &st); + if (r < 0) { + ERROR(self->ctx, "Could not stat %s: %m\n", path); + r = -errno; + goto ERROR; + } + // Make the filename r = pakfire_path_basename(filename, path); if (r < 0) @@ -2010,6 +2019,11 @@ static int pakfire_repo_metadata_add_file(struct pakfire_repo* self, if (r < 0) goto ERROR; + // Add the filesize + r = pakfire_json_add_uint64(file, "size", st.st_size); + if (r < 0) + goto ERROR; + // Add checksums r = pakfire_json_add_object(file, "chksums", &chksums); if (r < 0) -- 2.39.5