Move db_get_song into sub-handlers. (FReq 2112)
db_get_song was being called once for all sub-handlers, but with the addition of the find command, we don't have a URI coming in, so doing db_get_song once won't work anymore. [mk: fixed initialization order]
This commit is contained in:
parent
c51e1bf1c0
commit
c95fa4b441
@ -1510,17 +1510,17 @@ handle_idle(struct client *client,
|
||||
static enum command_return
|
||||
handle_sticker_song(struct client *client, int argc, char *argv[])
|
||||
{
|
||||
struct song *song = db_get_song(argv[3]);
|
||||
|
||||
if (song == NULL) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"no such song");
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (argc == 5 && strcmp(argv[1], "get") == 0) {
|
||||
struct song *song;
|
||||
char *value;
|
||||
|
||||
song = db_get_song(argv[3]);
|
||||
if (song == NULL) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"no such song");
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
value = sticker_song_get_value(song, argv[4]);
|
||||
if (value == NULL) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
@ -1533,7 +1533,17 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
|
||||
|
||||
return COMMAND_RETURN_OK;
|
||||
} else if (argc == 4 && strcmp(argv[1], "list") == 0) {
|
||||
struct sticker *sticker = sticker_song_get(song);
|
||||
struct song *song;
|
||||
struct sticker *sticker;
|
||||
|
||||
song = db_get_song(argv[3]);
|
||||
if (song == NULL) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"no such song");
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
sticker = sticker_song_get(song);
|
||||
if (NULL == sticker) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"no stickers found");
|
||||
@ -1545,8 +1555,16 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
|
||||
|
||||
return COMMAND_RETURN_OK;
|
||||
} else if (argc == 6 && strcmp(argv[1], "set") == 0) {
|
||||
struct song *song;
|
||||
bool ret;
|
||||
|
||||
song = db_get_song(argv[3]);
|
||||
if (song == NULL) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"no such song");
|
||||
return COMMAND_RETURN_ERROR;
|
||||
}
|
||||
|
||||
ret = sticker_song_set_value(song, argv[4], argv[5]);
|
||||
if (!ret) {
|
||||
command_error(client, ACK_ERROR_SYSTEM,
|
||||
|
Loading…
Reference in New Issue
Block a user