diff options
Diffstat (limited to 'src/dbi.c')
-rw-r--r-- | src/dbi.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -242,9 +242,16 @@ bool og_dbi_get_image(struct og_dbi *dbi, struct og_image *image) const char *msglog; dbi_result result; - result = dbi_conn_queryf(dbi->conn, - "SELECT nombreca, idimagen FROM imagenes WHERE nombreca = '%s'", - image->name); + /* old front-end needs this... */ + if (image->repo_id) { + result = dbi_conn_queryf(dbi->conn, + "SELECT nombreca, idimagen FROM imagenes WHERE nombreca = '%s'", + image->name); + } else { + result = dbi_conn_queryf(dbi->conn, + "SELECT nombreca, idimagen FROM imagenes WHERE nombreca = '%s' AND idrepositorio = '%s'", + image->name, image->repo_id); + } if (!result) { dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", @@ -262,17 +269,15 @@ bool og_dbi_get_image(struct og_dbi *dbi, struct og_image *image) return false; } -int og_dbi_get_repository_ip(const struct og_dbi *dbi, const uint64_t image_id, +int og_dbi_get_repository_ip(const struct og_dbi *dbi, const uint32_t repo_id, char *repository_ip) { const char *msglog, *dbi_repository_ip; dbi_result result; result = dbi_conn_queryf(dbi->conn, - "SELECT r.ip FROM imagenes i " - "JOIN repositorios r USING (idrepositorio) " - "WHERE i.idimagen = %lu", - image_id); + "SELECT ip FROM repositorios WHERE idrepositorio = %u", + repo_id); if (!result) { dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", @@ -283,8 +288,8 @@ int og_dbi_get_repository_ip(const struct og_dbi *dbi, const uint64_t image_id, if (!dbi_result_next_row(result)) { dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, - "image with id %lu has no repository (%s:%d) %s\n", - image_id, __func__, __LINE__, msglog); + "repository with id %u does not exist (%s:%d) %s\n", + repo_id, __func__, __LINE__, msglog); dbi_result_free(result); return -1; } |