diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-07-03 13:59:59 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-07-05 13:32:31 +0200 |
commit | 3f02d64104fede43074df2e0f229f514d24363fe (patch) | |
tree | 2010f57893ab3a49128bc2a83ddf001bdb471036 /src/client.c | |
parent | 23bd5f1a0703ffa1f6593489b1b544d8306bb82f (diff) |
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.
Diffstat (limited to 'src/client.c')
-rw-r--r-- | src/client.c | 13 |
1 files changed, 9 insertions, 4 deletions
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) { |