From 3f02d64104fede43074df2e0f229f514d24363fe Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Wed, 3 Jul 2024 13:59:59 +0200 Subject: rest: add checksum to GET /images Add a new checksum attribute to GET /images, extend database to add a new checksum field to images table. --- src/client.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/client.c') diff --git a/src/client.c b/src/client.c index 91927d7..4876f78 100644 --- a/src/client.c +++ b/src/client.c @@ -710,7 +710,8 @@ static bool og_dbi_update_image(struct og_dbi *dbi, static int update_image_info(struct og_dbi *dbi, const char *image_id, const char *clonator, const char *compressor, const char *filesystem, const uint64_t datasize, - uint64_t size, uint64_t lastupdate, uint32_t perms) + uint64_t size, uint64_t lastupdate, uint32_t perms, + const char *checksum) { const char *msglog; dbi_result result; @@ -719,9 +720,9 @@ static int update_image_info(struct og_dbi *dbi, const char *image_id, "UPDATE imagenes" " SET clonator='%s', compressor='%s'," " filesystem='%s', datasize=%lld, " - " size=%lld, lastupdate=%lld, permissions=%u " + " size=%lld, lastupdate=%lld, permissions=%u, checksum='%s' " " WHERE idimagen=%s", clonator, compressor, filesystem, - datasize, size, lastupdate, perms, image_id); + datasize, size, lastupdate, perms, checksum, image_id); if (!result) { dbi_conn_error(dbi->conn, &msglog); @@ -743,6 +744,7 @@ static int og_resp_image_create(json_t *data, struct og_client *cli) const char *compressor = NULL; const char *filesystem = NULL; const char *partition = NULL; + const char *checksum = NULL; const char *software = NULL; const char *image_id = NULL; const char *clonator = NULL; @@ -789,6 +791,8 @@ static int og_resp_image_create(json_t *data, struct og_client *cli) err = og_json_parse_uint64(value, &lastupdate); else if (!strcmp(key, "perms")) err = og_json_parse_uint(value, &perms); + else if (!strcmp(key, "checksum")) + err = og_json_parse_string(value, &checksum); if (err < 0) return err; @@ -846,7 +850,8 @@ static int og_resp_image_create(json_t *data, struct og_client *cli) } res = update_image_info(dbi, image_id, clonator, compressor, - filesystem, datasize, size, lastupdate, perms); + filesystem, datasize, size, lastupdate, perms, + checksum); og_dbi_close(dbi); if (res) { -- cgit v1.2.3-18-g5258