mirror of https://git.48k.eu/ogserver
client: split revision query when updating image information
a simple cleanup to help diagnose problems, not behaviour change expected.master v1.2.5-16
parent
a67c0d3d57
commit
a675dbb083
26
src/client.c
26
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);
|
||||
|
|
Loading…
Reference in New Issue