mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-28 15:06:02 -05:00
Fix for #23 -- playlist name or query can be null now
This commit is contained in:
parent
8d8178b46e
commit
c67af0fb50
33
src/db-sql.c
33
src/db-sql.c
@ -476,13 +476,17 @@ int db_sql_delete_playlist_item(char **pe, int playlistid, int songid) {
|
|||||||
* and the "where" clause.
|
* and the "where" clause.
|
||||||
*
|
*
|
||||||
* @param id id of the playlist to alter
|
* @param id id of the playlist to alter
|
||||||
* @param name new name of the playlist
|
* @param name new name of the playlist (or NULL)
|
||||||
* @param where new where clause
|
* @param where new where clause (or NULL)
|
||||||
* @returns DB_E_SUCCESS on success, error code otherwise
|
* @returns DB_E_SUCCESS on success, error code otherwise
|
||||||
*/
|
*/
|
||||||
int db_sql_edit_playlist(char **pe, int id, char *name, char *clause) {
|
int db_sql_edit_playlist(char **pe, int id, char *name, char *clause) {
|
||||||
int result;
|
int result;
|
||||||
int playlist_type;
|
int playlist_type;
|
||||||
|
int cnt;
|
||||||
|
|
||||||
|
if((name == NULL) && (clause == NULL))
|
||||||
|
return DB_E_SUCCESS; /* I guess?? */
|
||||||
|
|
||||||
/* first, check the playlist */
|
/* first, check the playlist */
|
||||||
result=db_sql_fetch_int(pe,&playlist_type,
|
result=db_sql_fetch_int(pe,&playlist_type,
|
||||||
@ -498,14 +502,31 @@ int db_sql_edit_playlist(char **pe, int id, char *name, char *clause) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: check for duplicate names here */
|
/* TODO: check for duplicate names here */
|
||||||
|
if(name) {
|
||||||
|
result = db_sql_fetch_int(pe,&cnt,"select count(*) from playlists "
|
||||||
|
"where upper(title)=upper('%q')",name);
|
||||||
|
|
||||||
|
if(result != DB_E_SUCCESS)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
if(cnt) {
|
||||||
|
db_get_error(pe,DB_E_DUPLICATE_PLAYLIST,name);
|
||||||
|
return DB_E_DUPLICATE_PLAYLIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((playlist_type == PL_SMART)&&(clause))
|
||||||
|
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q', "
|
||||||
|
"query='%q' where id=%d",name,clause,id);
|
||||||
|
|
||||||
if(playlist_type != PL_SMART) { /* Ignore the clause */
|
|
||||||
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q' "
|
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q' "
|
||||||
"where id=%d",name,id);
|
"where id=%d",name,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return db_sql_exec_fn(pe,E_LOG,"update playlists set title='%q',"
|
if((playlist_type == PL_SMART) && (clause))
|
||||||
"query='%q' where id=%d",name, clause, id);
|
return db_sql_exec_fn(pe,E_LOG,"update playlists set query='%q' "
|
||||||
|
"where id=%d",clause,id);
|
||||||
|
|
||||||
|
return DB_E_SUCCESS; /* ?? */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1118,10 +1118,9 @@ void dispatch_editplaylist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
|||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if((!ws_getvar(pwsc,"dmap.itemname")) ||
|
if(!ws_getvar(pwsc,"dmap.itemid")) {
|
||||||
(!ws_getvar(pwsc,"dmap.itemid"))) {
|
DPRINTF(E_LOG,L_DAAP,"Missing itemid on playlist edit");
|
||||||
DPRINTF(E_LOG,L_DAAP,"Missing name on playlist edit");
|
ws_returnerror(pwsc,500,"missing itemid on playlist name");
|
||||||
ws_returnerror(pwsc,500,"missing playlist name");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user