mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 07:53:23 -05:00
more fs case fixes
This commit is contained in:
parent
f9d27a4773
commit
f3fecf593e
162
src/db-sql.c
162
src/db-sql.c
@ -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,80 +877,94 @@ 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
|
"genre='%q'," // genre
|
||||||
"genre='%q'," // genre
|
"comment='%q'," // comment
|
||||||
"comment='%q'," // comment
|
"type='%q'," // type
|
||||||
"type='%q'," // type
|
"composer='%q'," // composer
|
||||||
"composer='%q'," // composer
|
"orchestra='%q'," // orchestra
|
||||||
"orchestra='%q'," // orchestra
|
"conductor='%q'," // conductor
|
||||||
"conductor='%q'," // conductor
|
"grouping='%q'," // grouping
|
||||||
"grouping='%q'," // grouping
|
"url='%q'," // url
|
||||||
"url='%q'," // url
|
"bitrate=%d," // bitrate
|
||||||
"bitrate=%d," // bitrate
|
"samplerate=%d," // samplerate
|
||||||
"samplerate=%d," // samplerate
|
"song_length=%d," // song_length
|
||||||
"song_length=%d," // song_length
|
"file_size=%d," // file_size
|
||||||
"file_size=%d," // file_size
|
"year=%d," // year
|
||||||
"year=%d," // year
|
"track=%d," // track
|
||||||
"track=%d," // track
|
"total_tracks=%d," // total_tracks
|
||||||
"total_tracks=%d," // total_tracks
|
"disc=%d," // disc
|
||||||
"disc=%d," // disc
|
"total_discs=%d," // total_discs
|
||||||
"total_discs=%d," // total_discs
|
"time_modified=%d," // time_modified
|
||||||
"time_modified=%d," // time_modified
|
"db_timestamp=%d," // db_timestamp
|
||||||
"db_timestamp=%d," // db_timestamp
|
"bpm=%d," // bpm
|
||||||
"bpm=%d," // bpm
|
"disabled=%d," // disabled
|
||||||
"disabled=%d," // disabled
|
"compilation=%d," // compilation
|
||||||
"compilation=%d," // compilation
|
"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",
|
|
||||||
STR(pmp3->title),
|
if(conf_get_int("scanning","case_sensitive",0)) {
|
||||||
STR(pmp3->artist),
|
strcat(query," WHERE path='%q' and idx=%d");
|
||||||
STR(pmp3->album),
|
} else {
|
||||||
STR(pmp3->genre),
|
strcat(query," WHERE upper(path)=upper('%q') and idx=%d");
|
||||||
STR(pmp3->comment),
|
}
|
||||||
STR(pmp3->type),
|
|
||||||
STR(pmp3->composer),
|
err = db_sql_exec_fn(pe,E_LOG,query,
|
||||||
STR(pmp3->orchestra),
|
STR(pmp3->title),
|
||||||
STR(pmp3->conductor),
|
STR(pmp3->artist),
|
||||||
STR(pmp3->grouping),
|
STR(pmp3->album),
|
||||||
STR(pmp3->url),
|
STR(pmp3->genre),
|
||||||
pmp3->bitrate,
|
STR(pmp3->comment),
|
||||||
pmp3->samplerate,
|
STR(pmp3->type),
|
||||||
pmp3->song_length,
|
STR(pmp3->composer),
|
||||||
pmp3->file_size,
|
STR(pmp3->orchestra),
|
||||||
pmp3->year,
|
STR(pmp3->conductor),
|
||||||
pmp3->track,
|
STR(pmp3->grouping),
|
||||||
pmp3->total_tracks,
|
STR(pmp3->url),
|
||||||
pmp3->disc,
|
pmp3->bitrate,
|
||||||
pmp3->total_discs,
|
pmp3->samplerate,
|
||||||
pmp3->time_modified,
|
pmp3->song_length,
|
||||||
pmp3->db_timestamp,
|
pmp3->file_size,
|
||||||
pmp3->bpm,
|
pmp3->year,
|
||||||
pmp3->disabled,
|
pmp3->track,
|
||||||
pmp3->compilation,
|
pmp3->total_tracks,
|
||||||
pmp3->rating,
|
pmp3->disc,
|
||||||
pmp3->sample_count,
|
pmp3->total_discs,
|
||||||
STR(pmp3->codectype),
|
pmp3->time_modified,
|
||||||
pmp3->path,
|
pmp3->db_timestamp,
|
||||||
pmp3->index);
|
pmp3->bpm,
|
||||||
|
pmp3->disabled,
|
||||||
|
pmp3->compilation,
|
||||||
|
pmp3->rating,
|
||||||
|
pmp3->sample_count,
|
||||||
|
STR(pmp3->codectype),
|
||||||
|
pmp3->path,
|
||||||
|
pmp3->index);
|
||||||
|
|
||||||
if(err != DB_E_SUCCESS)
|
if(err != DB_E_SUCCESS)
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user