Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
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)
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)