summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-06-20 09:40:48 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-06-20 10:41:50 +0200
commit30d6af09d5db938612b6ea803c5f88ea531cf7b7 (patch)
tree15796ade39995c401ea8dc37acaf4c3e6154b3ad /src
parent52a38d3e574fb25b47d230bc87754583eb17b4a6 (diff)
#915 Use the repository id on image list
API "GET /images" shows the repository ID the image belongs to, instead of the IP. This is a preparative commit to the support of repositories with several IPs. Request GET /images Response 200 OK: { "images": [ { "name": "windows10", "datasize": 0, "size": 626088433, "modified": "Fri Jun 10 12:20:32 2022", "permissions": "744", "software_id": 1, "type": 1, "id": 6, "repo_id": 1 } ], "disk": { "total": 52573995008, "free": 38964637696 } }
Diffstat (limited to 'src')
-rw-r--r--src/dbi.h1
-rw-r--r--src/rest.c13
2 files changed, 5 insertions, 9 deletions
diff --git a/src/dbi.h b/src/dbi.h
index bebae02..5f6b52e 100644
--- a/src/dbi.h
+++ b/src/dbi.h
@@ -53,7 +53,6 @@ struct og_image_legacy {
struct og_image {
char name[OG_DB_IMAGE_NAME_MAXLEN + 1];
char description[OG_DB_IMAGE_DESCRIPTION_MAXLEN + 1];
- char repo_ip[OG_DB_IP_MAXLEN + 1];
uint64_t software_id;
uint64_t center_id;
uint64_t datasize;
diff --git a/src/rest.c b/src/rest.c
index 4e12643..f539426 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -2036,8 +2036,8 @@ static json_t *og_json_image_alloc(struct og_image *image)
json_integer(image->type));
json_object_set_new(image_json, "id",
json_integer(image->id));
- json_object_set_new(image_json, "repo_ip",
- json_string(image->repo_ip));
+ json_object_set_new(image_json, "repo_id",
+ json_integer(image->repo_id));
return image_json;
}
@@ -2077,12 +2077,10 @@ static int og_cmd_images(char *buffer_reply)
" i.clonator, i.compressor, "
" i.filesystem, i.datasize, "
" i.idperfilsoft, i.tipo, "
- " i.idimagen, r.ip "
+ " i.idimagen, i.idrepositorio "
"FROM imagenes i "
"LEFT JOIN ordenadores o "
- "ON i.idordenador = o.idordenador "
- "JOIN repositorios r "
- "ON i.idrepositorio = r.idrepositorio");
+ "ON i.idordenador = o.idordenador ");
while (dbi_result_next_row(result)) {
image = (struct og_image){0};
@@ -2090,8 +2088,7 @@ static int og_cmd_images(char *buffer_reply)
image.software_id = dbi_result_get_ulonglong(result, "idperfilsoft");
image.type = dbi_result_get_ulonglong(result, "tipo");
image.id = dbi_result_get_ulonglong(result, "idimagen");
- snprintf(image.repo_ip, sizeof(image.repo_ip), "%s",
- dbi_result_get_string(result, "ip"));
+ image.repo_id = dbi_result_get_ulonglong(result, "idrepositorio");
snprintf(image.name, sizeof(image.name), "%s",
dbi_result_get_string(result, "nombreca"));