summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-19 14:13:57 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-19 14:23:30 +0200
commita675dbb083af5bd64e33097754042cf54fef8b8b (patch)
treef0e0ec9bcddbf2daf301fc6975a18a37a3627f51 /src/client.c
parenta67c0d3d5756642373097261bc503f18f123e933 (diff)
client: split revision query when updating image informationv1.2.5-16
a simple cleanup to help diagnose problems, not behaviour change expected.
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c26
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);