diff --git a/src/db.c b/src/db.c index a08bbf4b..6afe9203 100644 --- a/src/db.c +++ b/src/db.c @@ -3008,21 +3008,6 @@ db_pl_add(struct playlist_info *pli, int *id) #undef QADD_TMPL } -int -db_pl_add_item_byfile(int plid, const char *filename) -{ -#define Q_TMPL "INSERT INTO playlistitems (playlistid, filepath) SELECT %d, path FROM files WHERE fname='%q' GROUP BY fname HAVING COUNT(*)=1;" - char *query; - int ret; - - query = sqlite3_mprintf(Q_TMPL, plid, filename); - - ret = db_query_run(query, 1, 0); - - return ((ret < 0) ? -1 : sqlite3_changes(hdl)); -#undef Q_TMPL -} - int db_pl_add_item_bypath(int plid, const char *path) { diff --git a/src/db.h b/src/db.h index 932083a5..f3ce17f6 100644 --- a/src/db.h +++ b/src/db.h @@ -597,9 +597,6 @@ db_pl_fetch_bytitlepath(const char *title, const char *path); int db_pl_add(struct playlist_info *pli, int *id); -int -db_pl_add_item_byfile(int plid, const char *filename); - int db_pl_add_item_bypath(int plid, const char *path); diff --git a/src/db_init.c b/src/db_init.c index 7d873b0d..d9534b5c 100644 --- a/src/db_init.c +++ b/src/db_init.c @@ -294,7 +294,7 @@ static const struct db_init_query db_init_table_queries[] = "CREATE INDEX IF NOT EXISTS idx_rescan ON files(path, db_timestamp);" #define I_FNAME \ - "CREATE INDEX IF NOT EXISTS idx_fname ON files(disabled, fname);" + "CREATE INDEX IF NOT EXISTS idx_fname ON files(disabled, fname COLLATE NOCASE);" #define I_SONGARTISTID \ "CREATE INDEX IF NOT EXISTS idx_sari ON files(songartistid);" diff --git a/src/library/filescanner_playlist.c b/src/library/filescanner_playlist.c index 47e83e90..c76b6c6d 100644 --- a/src/library/filescanner_playlist.c +++ b/src/library/filescanner_playlist.c @@ -149,16 +149,7 @@ process_regular_file(int pl_id, char *path) path[i] = '/'; } - // Fast path - only works if there are not multiple items in the lib with the - // same filename -/* ret = db_pl_add_item_byfile(pl_id, filename_from_path(path)); - if (ret == 1) - return 0; - - DPRINTF(E_DBG, L_SCAN, "Fast path adding '%s' to playlist did not work (ret=%d), now searching\n", path, ret); -*/ - - ret = db_snprintf(filter, sizeof(filter), "f.fname = '%q'", filename_from_path(path)); // TODO make case insensitive? + ret = db_snprintf(filter, sizeof(filter), "f.fname = '%q' COLLATE NOCASE", filename_from_path(path)); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Path in playlist is too long: '%s'\n", path); @@ -184,8 +175,6 @@ process_regular_file(int pl_id, char *path) { if (qp.results == 1) { - DPRINTF(E_DBG, L_SCAN, "Adding '%s' to playlist %d (fast path)\n", dbpath, pl_id); - winner = strdup(dbpath); break; } @@ -193,7 +182,7 @@ process_regular_file(int pl_id, char *path) for (i = 0, a = NULL, b = NULL; (parent_dir(&a, path) == 0) && (parent_dir(&b, dbpath) == 0) && (strcasecmp(a, b) == 0); i++) ; - DPRINTF(E_DBG, L_SCAN, "Comparison of '%s' and '%s' gave score %d\n", dbpath, path, i); + DPRINTF(E_SPAM, L_SCAN, "Comparison of '%s' and '%s' gave score %d\n", dbpath, path, i); if (i > score) { @@ -216,6 +205,8 @@ process_regular_file(int pl_id, char *path) return -1; } + DPRINTF(E_DBG, L_SCAN, "Adding '%s' to playlist %d (results %d)\n", dbpath, pl_id, qp.results); + db_pl_add_item_bypath(pl_id, winner); free(winner);