diff options
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); |