diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-12-12 16:49:25 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-12-12 17:02:44 +0100 |
commit | ee09056908bc925d018a5466629872434ac3edf6 (patch) | |
tree | 92866106311664e5e0558e83dc9ac101dc3c6cec /src/rest.c | |
parent | e3b8f3d2f9ea5f1b3ea68c4d5ba862680f7851fa (diff) |
client: parse permissions and lastupdate in /image/create response from clientv1.2.5-5
Use permissions and last update from client.
update src/schema.c to add a new database version.
Diffstat (limited to 'src/rest.c')
-rw-r--r-- | src/rest.c | 30 |
1 files changed, 8 insertions, 22 deletions
@@ -2424,20 +2424,6 @@ static const int og_cmd_get_repositories(char *buffer_reply) #define OG_IMAGE_TYPE_MAXLEN 4 -static int og_get_image_stats(const char *name, - struct stat *image_stats) -{ - const char *dir = ogconfig.repo.dir; - char filename[PATH_MAX + 1]; - - snprintf(filename, sizeof(filename), "%s/%s.img", dir, name); - if (stat(filename, image_stats) < 0) { - syslog(LOG_ERR, "%s image does not exists", name); - return -1; - } - return 0; -} - static json_t *og_json_disk_alloc() { const char *dir = ogconfig.repo.dir; @@ -2469,16 +2455,14 @@ static json_t *og_json_image_alloc(struct og_image *image) char perms_string[OG_PERMS_MAXLEN]; json_t *image_json; char *modified; - uint16_t perms; image_json = json_object(); if (!image_json) return NULL; - perms = image->image_stats.st_mode & OG_PERMS_IRWX; - snprintf(perms_string, sizeof(perms_string), "%o", perms); + snprintf(perms_string, sizeof(perms_string), "%o", image->perms); - modified = ctime(&image->image_stats.st_mtime); + modified = ctime(&image->lastupdate); modified[strlen(modified) - 1] = '\0'; json_object_set_new(image_json, "name", @@ -2486,7 +2470,7 @@ static json_t *og_json_image_alloc(struct og_image *image) json_object_set_new(image_json, "datasize", json_integer(image->datasize)); json_object_set_new(image_json, "size", - json_integer(image->image_stats.st_size)); + json_integer(image->size)); json_object_set_new(image_json, "modified", json_string(modified)); json_object_set_new(image_json, "permissions", @@ -2538,7 +2522,8 @@ static int og_cmd_images(char *buffer_reply) result = dbi_conn_queryf(dbi->conn, "SELECT i.nombreca, o.nombreordenador, " " i.clonator, i.compressor, " - " i.filesystem, i.datasize, " + " i.filesystem, i.datasize, i.size, " + " i.lastupdate, i.permissions, " " i.idperfilsoft, i.tipo, " " i.idimagen, i.idrepositorio, " " i.descripcion " @@ -2549,6 +2534,9 @@ static int og_cmd_images(char *buffer_reply) while (dbi_result_next_row(result)) { image = (struct og_image){0}; image.datasize = dbi_result_get_ulonglong(result, "datasize"); + image.size = dbi_result_get_ulonglong(result, "size"); + image.lastupdate = dbi_result_get_ulonglong(result, "lastupdate"); + image.perms = dbi_result_get_uint(result, "permissions"); 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"); @@ -2558,8 +2546,6 @@ static int og_cmd_images(char *buffer_reply) snprintf(image.description, sizeof(image.description), "%s", dbi_result_get_string(result, "descripcion")); - og_get_image_stats(image.name, &image.image_stats); - image_json = og_json_image_alloc(&image); if (!image_json) { dbi_result_free(result); |