summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c53
1 files changed, 2 insertions, 51 deletions
diff --git a/src/rest.c b/src/rest.c
index 3f10685..dee85e1 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -3814,55 +3814,6 @@ static int og_cmd_restore_image(json_t *element, struct og_msg_params *params)
body);
}
-static int og_delete_image(struct og_dbi *dbi, const uint32_t image_id)
-{
- char filename[PATH_MAX + 1], checksum[PATH_MAX + 1];
- const char *image;
- dbi_result result;
-
- result = dbi_conn_queryf(dbi->conn,
- "SELECT nombreca FROM imagenes "
- "WHERE idimagen='%u'",
- image_id);
- if (!result) {
- syslog(LOG_ERR, "failed to query database\n");
- return -1;
- }
- if (!dbi_result_next_row(result)) {
- dbi_result_free(result);
- syslog(LOG_ERR, "image \"%u\" does not exist in database\n", image_id);
- return -1;
- }
-
- image = dbi_result_get_string(result, "nombreca");
- snprintf(filename, sizeof(filename), "%s/%s.img", ogconfig.repo.dir,
- image);
- snprintf(checksum, sizeof(checksum), "%s/%s.img.full.sum", ogconfig.repo.dir,
- image);
- dbi_result_free(result);
-
- result = dbi_conn_queryf(dbi->conn,
- "DELETE FROM imagenes "
- "WHERE idimagen='%u'",
- image_id);
- if (!result) {
- syslog(LOG_ERR, "failed to query database\n");
- return -1;
- }
- if (dbi_result_get_numrows_affected(result) < 1) {
- syslog(LOG_ERR, "delete did not modify any row (%s:%d)\n",
- __func__, __LINE__);
- dbi_result_free(result);
- return -1;
- }
- dbi_result_free(result);
-
- unlink(filename);
- unlink(checksum);
-
- return 0;
-}
-
static int og_cmd_delete_image(json_t *element, struct og_msg_params *params)
{
struct og_dbi *dbi;
@@ -3893,7 +3844,7 @@ static int og_cmd_delete_image(json_t *element, struct og_msg_params *params)
return -1;
}
- err = og_delete_image(dbi, atoi(params->id));
+ err = og_dbi_delete_image(dbi, atoi(params->id));
if (err < 0) {
og_dbi_close(dbi);
return err;
@@ -4771,7 +4722,7 @@ static int og_cmd_post_center_delete(json_t *element,
while (dbi_result_next_row(result)) {
image_id = dbi_result_get_uint(result, "idimagen");
- err = og_delete_image(dbi, image_id);
+ err = og_dbi_delete_image(dbi, image_id);
if (err < 0) {
dbi_result_free(result);
og_dbi_close(dbi);