From: Michael Tremer Date: Sun, 2 Feb 2025 15:00:12 +0000 (+0000) Subject: repos: Add filesize to metadata X-Git-Tag: 0.9.30~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1a96658d4daf4607e381897b3950feb76e59b2a;p=pakfire.git repos: Add filesize to metadata Signed-off-by: Michael Tremer --- 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)