[db] Refactor fetching query result into generic function

Additionally changes the return value in case the end of the result set
is reached.
This commit is contained in:
chme
2021-12-28 06:55:35 +01:00
parent d7086cab00
commit a65ee4462e
9 changed files with 59 additions and 113 deletions

View File

@@ -1766,7 +1766,7 @@ process_items(struct artwork_ctx *ctx, int item_mode)
return -1;
}
while (((ret = db_query_fetch_file(&ctx->qp, &dbmfi)) == 0) && (dbmfi.id))
while ((ret = db_query_fetch_file(&ctx->qp, &dbmfi)) == 0)
{
// Save the first songalbumid, might need it for process_group() if this search doesn't give anything
if (!ctx->persistentid)
@@ -1859,7 +1859,7 @@ process_group(struct artwork_ctx *ctx)
goto invalid_group;
}
is_valid = (db_query_fetch_file(&ctx->qp, &dbmfi) == 0 && dbmfi.id && strcmp(dbmfi.album, CFG_NAME_UNKNOWN_ALBUM) != 0 && strcmp(dbmfi.album_artist, CFG_NAME_UNKNOWN_ARTIST) != 0);
is_valid = (db_query_fetch_file(&ctx->qp, &dbmfi) == 0 && strcmp(dbmfi.album, CFG_NAME_UNKNOWN_ALBUM) != 0 && strcmp(dbmfi.album_artist, CFG_NAME_UNKNOWN_ARTIST) != 0);
db_query_end(&ctx->qp);
if (!is_valid)
{