diff --git a/src/base/commands.c b/src/base/commands.c index edd5f42bd07cc25d7a93315e28a0ed8297a3fb44..20926b1fb18c3baf3fbe026a6b3490f17086275a 100644 --- a/src/base/commands.c +++ b/src/base/commands.c @@ -368,8 +368,12 @@ command_addid(struct lkt_state *srv, char *args[LKT_MESSAGE_ARGS_MAX]) RETURN_UNLESS(args, "Invalid argument", false); errno = 0; int i, id; - for (i = 0, id = strtol(args[i], NULL, 0); id != 0 && !errno; ++i, id = strtol(args[i], NULL, 0)) - errno |= database_queue_add_id(srv->db, id, 1); + for (i = 0; !errno && args[i]; ++i) { + id = strtol(args[i], NULL, 0); + if (id == 0) + break; + errno |= !database_queue_add_id(srv->db, id, 1); + } srv->mpd_idle_events |= MPD_IDLE_PLAYLIST; return !errno; } diff --git a/src/database/queue.c b/src/database/queue.c index 9e20c08c1ad44c5751e18b84e1e3e63a71f4513c..10427be60257d8eccf57eba2bec8e9fa1e1fb2dc 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -294,11 +294,18 @@ database_queue_add_id(lkt_db *db, int id, int priority) reorder(db, priority, error_no_stmt); SQLITE_EXEC(db, "COMMIT;", error); - LOG_INFO("DB-DEBUG", "Added kara with id %d and priority %d", id, priority); return true; error: + LOG_ERROR("DB", + "Error while adding the kara id %d into the queue with the " + "priority %d", + id, priority); sqlite3_finalize(stmt); error_no_stmt: + LOG_ERROR("DB", + "Need to rollback the queue because of failed insertion of id " + "%d with priority %d in the queue", + id, priority); SQLITE_DO_ROLLBACK(db); __queue_resequence(db); return false;