diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/client.c b/src/client.c index 0d898d7..ca446d7 100644 --- a/src/client.c +++ b/src/client.c @@ -624,6 +624,7 @@ static bool og_dbi_update_image(struct og_dbi *dbi, const char *msglog; dbi_result result; int repo_id, sw_id; + uint32_t revision; /* find repository identifier by repository ip and computer ID. */ result = dbi_conn_queryf(dbi->conn, @@ -688,13 +689,32 @@ static bool og_dbi_update_image(struct og_dbi *dbi, } dbi_result_free(result); + result = dbi_conn_queryf(dbi->conn, + "SELECT revision FROM imagenes WHERE idimagen=%s", + img_info->image_id); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", + __func__, __LINE__, msglog); + return false; + } + + if (!dbi_result_next_row(result)) { + syslog(LOG_ERR, + "no image found with id '%s' database (%s:%d)\n", + img_info->image_id, __func__, __LINE__); + dbi_result_free(result); + return false; + } + revision = dbi_result_get_uint(result, "revision"); + dbi_result_free(result); + /* attach image to partition. */ result = dbi_conn_queryf(dbi->conn, "UPDATE ordenadores_particiones" - " SET idimagen=%s, revision=(SELECT revision FROM imagenes WHERE idimagen=%s)," - " fechadespliegue=NOW()" + " SET idimagen=%s, revision=%u, fechadespliegue=NOW()" " WHERE idordenador=%s AND numdisk=%s AND numpar=%s", - img_info->image_id, img_info->image_id, + img_info->image_id, revision, computer_id, img_info->disk, img_info->part); if (!result) { dbi_conn_error(dbi->conn, &msglog); |