summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-03 13:59:59 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-05 13:32:31 +0200
commit3f02d64104fede43074df2e0f229f514d24363fe (patch)
tree2010f57893ab3a49128bc2a83ddf001bdb471036 /src/rest.c
parent23bd5f1a0703ffa1f6593489b1b544d8306bb82f (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/rest.c')
-rw-r--r--src/rest.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index 81c3dd9..d415f0f 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -3325,6 +3325,8 @@ static json_t *og_json_image_alloc(struct og_image *image)
json_integer(image->repo_id));
json_object_set_new(image_json, "description",
json_string(image->description));
+ json_object_set_new(image_json, "checksum",
+ json_string(image->checksum));
return image_json;
}
@@ -3366,7 +3368,7 @@ static int og_cmd_images(char *buffer_reply)
" i.lastupdate, i.permissions, "
" i.idperfilsoft, i.tipo, "
" i.idimagen, i.idrepositorio, "
- " i.descripcion "
+ " i.descripcion, i.checksum "
"FROM imagenes i "
"LEFT JOIN ordenadores o "
"ON i.idordenador = o.idordenador ");
@@ -3381,10 +3383,14 @@ static int og_cmd_images(char *buffer_reply)
image.type = dbi_result_get_ulonglong(result, "tipo");
image.id = dbi_result_get_ulonglong(result, "idimagen");
image.repo_id = dbi_result_get_ulonglong(result, "idrepositorio");
+ snprintf(image.checksum, sizeof(image.checksum), "%s",
+ dbi_result_get_string(result, "checksum"));
snprintf(image.name, sizeof(image.name), "%s",
dbi_result_get_string(result, "nombreca"));
snprintf(image.description, sizeof(image.description), "%s",
dbi_result_get_string(result, "descripcion"));
+ snprintf(image.checksum, sizeof(image.checksum), "%s",
+ dbi_result_get_string(result, "checksum"));
image_json = og_json_image_alloc(&image);
if (!image_json) {