more fs case fixes

This commit is contained in:
Ron Pedde 2006-08-14 00:00:54 +00:00
parent f9d27a4773
commit f3fecf593e

View File

@ -735,6 +735,7 @@ int db_sql_add(char **pe, MP3FILE *pmp3, int *id) {
int err; int err;
int count; int count;
int insertid; int insertid;
char *query;
DPRINTF(E_SPAM,L_DB,"Entering db_sql_add\n"); DPRINTF(E_SPAM,L_DB,"Entering db_sql_add\n");
@ -746,11 +747,16 @@ int db_sql_add(char **pe, MP3FILE *pmp3, int *id) {
pmp3->db_timestamp = (int)time(NULL); pmp3->db_timestamp = (int)time(NULL);
if(conf_get_int("scanning","case_sensitive",0)) {
query = "select count(*) from songs where path='%q' and idx=%d";
} else {
query = "select count(*) from songs where upper(path)=upper('%q') and"
" idx=%d";
}
/* Always an add if in song scan on full reload */ /* Always an add if in song scan on full reload */
if((!db_sql_reload)||(!db_sql_in_scan)) { if((!db_sql_reload)||(!db_sql_in_scan)) {
err=db_sql_fetch_int(NULL,&count,"select count(*) from songs where " err=db_sql_fetch_int(NULL,&count,query,pmp3->path,pmp3->index);
"path='%q' and idx=%d",pmp3->path,pmp3->index);
if((err == DB_E_SUCCESS) && (count == 1)) { /* we should update */ if((err == DB_E_SUCCESS) && (count == 1)) { /* we should update */
return db_sql_update(pe,pmp3,id); return db_sql_update(pe,pmp3,id);
@ -871,14 +877,14 @@ int db_sql_add(char **pe, MP3FILE *pmp3, int *id) {
*/ */
int db_sql_update(char **pe, MP3FILE *pmp3, int *id) { int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
int err; int err;
char query[1024];
if(!pmp3->time_modified) if(!pmp3->time_modified)
pmp3->time_modified = (int)time(NULL); pmp3->time_modified = (int)time(NULL);
pmp3->db_timestamp = (int)time(NULL); pmp3->db_timestamp = (int)time(NULL);
/* FIXME: this should update all fields */ strcpy(query,"UPDATE songs SET "
err=db_sql_exec_fn(pe,E_LOG,"UPDATE songs SET "
"title='%q'," // title "title='%q'," // title
"artist='%q'," // artist "artist='%q'," // artist
"album='%q'," // album "album='%q'," // album
@ -907,7 +913,15 @@ int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
"rating=%d," // rating "rating=%d," // rating
"sample_count=%d," // sample_count "sample_count=%d," // sample_count
"codectype='%q'" // codec "codectype='%q'" // codec
" WHERE path='%q' and idx=%d", );
if(conf_get_int("scanning","case_sensitive",0)) {
strcat(query," WHERE path='%q' and idx=%d");
} else {
strcat(query," WHERE upper(path)=upper('%q') and idx=%d");
}
err = db_sql_exec_fn(pe,E_LOG,query,
STR(pmp3->title), STR(pmp3->title),
STR(pmp3->artist), STR(pmp3->artist),
STR(pmp3->album), STR(pmp3->album),
@ -943,8 +957,14 @@ int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
DPRINTF(E_FATAL,L_DB,"Error updating file: %s\n",pmp3->fname); DPRINTF(E_FATAL,L_DB,"Error updating file: %s\n",pmp3->fname);
if(id) { /* we need the insert/update id */ if(id) { /* we need the insert/update id */
err=db_sql_fetch_int(pe,id,"select id from songs where path='%q' and " if(conf_get_int("scanning","case_sensitive",0)) {
"idx=%d",pmp3->path,pmp3->index); strcpy(query,"select id from songs where path='%q' and idx=%d");
} else {
strcpy(query,"select id from songs where upper(path)=upper('%q') "
"and idx=%d");
}
err=db_sql_fetch_int(pe,id,query,pmp3->path,pmp3->index);
if(err != DB_E_SUCCESS) if(err != DB_E_SUCCESS)
return err; return err;
} }
@ -953,9 +973,15 @@ int db_sql_update(char **pe, MP3FILE *pmp3, int *id) {
if(id) { if(id) {
db_sql_exec_fn(NULL,E_FATAL,"insert into updated (id) values (%d)",*id); db_sql_exec_fn(NULL,E_FATAL,"insert into updated (id) values (%d)",*id);
} else { } else {
db_sql_exec_fn(NULL,E_FATAL,"insert into updated (id) " if(conf_get_int("scanning","case_sensitive",0)) {
"select id from songs where path='%q' and idx=%d", strcpy(query,"insert into updated (id) select id from "
pmp3->path,pmp3->index); "songs where path='%q' and idx=%d");
} else {
strcpy(query,"insert into updated (id) select id from "
"songs where upper(path)=upper('%q') and idx=%d");
}
db_sql_exec_fn(NULL,E_FATAL,query,pmp3->path,pmp3->index);
} }
} }