Fix playlist updating when updating smart playlist but not editing name. Fixes ticket #56

This commit is contained in:
Ron Pedde 2006-04-10 05:14:43 +00:00
parent 86a44ea550
commit 61d2cd0df1
1 changed files with 7 additions and 4 deletions

View File

@ -486,7 +486,7 @@ int db_sql_delete_playlist_item(char **pe, int playlistid, int songid) {
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; int dup_id=id;
if((name == NULL) && (clause == NULL)) if((name == NULL) && (clause == NULL))
return DB_E_SUCCESS; /* I guess?? */ return DB_E_SUCCESS; /* I guess?? */
@ -511,13 +511,16 @@ 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) { if(name) {
result = db_sql_fetch_int(pe,&cnt,"select count(*) from playlists " result = db_sql_fetch_int(pe,&dup_id,"select id from playlists "
"where upper(title)=upper('%q')",name); "where upper(title)=upper('%q')",name);
if(result != DB_E_SUCCESS) if((result != DB_E_SUCCESS) && (result != DB_E_NOROWS))
return result; return result;
if(cnt) { if(result == DB_E_NOROWS)
if(pe) free(*pe);
if(dup_id != id) {
db_get_error(pe,DB_E_DUPLICATE_PLAYLIST,name); db_get_error(pe,DB_E_DUPLICATE_PLAYLIST,name);
return DB_E_DUPLICATE_PLAYLIST; return DB_E_DUPLICATE_PLAYLIST;
} }