mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-26 12:59:19 -05:00
Remove default playlist & special case
The default playlist (called "Library") doesn't actually have a purpose; I though it was needed for RSP (SoundBridge) but it doesn't look like it makes any difference with or without this playlist.
This commit is contained in:
parent
1b34c9d555
commit
af95cee79b
37
src/db.c
37
src/db.c
@ -339,8 +339,8 @@ db_purge_cruft(time_t ref)
|
|||||||
char *queries[3] = { NULL, NULL, NULL };
|
char *queries[3] = { NULL, NULL, NULL };
|
||||||
char *queries_tmpl[3] =
|
char *queries_tmpl[3] =
|
||||||
{
|
{
|
||||||
"DELETE FROM playlistitems WHERE playlistid IN (SELECT id FROM playlists WHERE id <> 1 AND db_timestamp < %" PRIi64 ");",
|
"DELETE FROM playlistitems WHERE playlistid IN (SELECT id FROM playlists WHERE db_timestamp < %" PRIi64 ");",
|
||||||
"DELETE FROM playlists WHERE id <> 1 AND db_timestamp < %" PRIi64 ";",
|
"DELETE FROM playlists WHERE db_timestamp < %" PRIi64 ";",
|
||||||
"DELETE FROM files WHERE db_timestamp < %" PRIi64 ";"
|
"DELETE FROM files WHERE db_timestamp < %" PRIi64 ";"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -556,22 +556,12 @@ db_build_query_plitems(struct query_params *qp, char **q)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qp->pl_id == 1)
|
|
||||||
{
|
|
||||||
if (qp->filter)
|
|
||||||
count = sqlite3_mprintf("SELECT COUNT(*) FROM files WHERE disabled = 0 AND %s;", qp->filter);
|
|
||||||
else
|
|
||||||
count = sqlite3_mprintf("SELECT COUNT(*) FROM files WHERE disabled = 0;");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (qp->filter)
|
if (qp->filter)
|
||||||
count = sqlite3_mprintf("SELECT COUNT(*) FROM files JOIN playlistitems ON files.path = playlistitems.filepath"
|
count = sqlite3_mprintf("SELECT COUNT(*) FROM files JOIN playlistitems ON files.path = playlistitems.filepath"
|
||||||
" WHERE playlistitems.playlistid = %d AND files.disabled = 0 AND %s;", qp->pl_id, qp->filter);
|
" WHERE playlistitems.playlistid = %d AND files.disabled = 0 AND %s;", qp->pl_id, qp->filter);
|
||||||
else
|
else
|
||||||
count = sqlite3_mprintf("SELECT COUNT(*) FROM files JOIN playlistitems ON files.path = playlistitems.filepath"
|
count = sqlite3_mprintf("SELECT COUNT(*) FROM files JOIN playlistitems ON files.path = playlistitems.filepath"
|
||||||
" WHERE playlistitems.playlistid = %d AND files.disabled = 0;", qp->pl_id);
|
" WHERE playlistitems.playlistid = %d AND files.disabled = 0;", qp->pl_id);
|
||||||
}
|
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
@ -1879,10 +1869,6 @@ db_pl_fetch_byquery(char *query)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Playlist 1: all files */
|
|
||||||
if (pli->id == 1)
|
|
||||||
pli->items = db_files_get_count();
|
|
||||||
else
|
|
||||||
pli->items = db_pl_count_items(pli->id);
|
pli->items = db_pl_count_items(pli->id);
|
||||||
|
|
||||||
return pli;
|
return pli;
|
||||||
@ -2890,10 +2876,6 @@ db_perthread_deinit(void)
|
|||||||
" libidx INTEGER NOT NULL" \
|
" libidx INTEGER NOT NULL" \
|
||||||
");"
|
");"
|
||||||
|
|
||||||
#define Q_PL1 \
|
|
||||||
"INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx)" \
|
|
||||||
" VALUES(1, 'Library', 1, '1', 0, '', 0);"
|
|
||||||
|
|
||||||
#define I_PATH \
|
#define I_PATH \
|
||||||
"CREATE INDEX IF NOT EXISTS idx_path ON files(path, idx);"
|
"CREATE INDEX IF NOT EXISTS idx_path ON files(path, idx);"
|
||||||
|
|
||||||
@ -2947,21 +2929,6 @@ db_create_tables(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = db_get_count("SELECT COUNT(*) FROM playlists WHERE id = 1;");
|
|
||||||
if (ret != 1)
|
|
||||||
{
|
|
||||||
DPRINTF(E_DBG, L_DB, "Creating default playlist\n");
|
|
||||||
|
|
||||||
ret = sqlite3_exec(hdl, Q_PL1, NULL, NULL, &errmsg);
|
|
||||||
if (ret != SQLITE_OK)
|
|
||||||
{
|
|
||||||
DPRINTF(E_FATAL, L_DB, "Could not add default playlist: %s\n", errmsg);
|
|
||||||
|
|
||||||
sqlite3_free(errmsg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = db_get_count("SELECT COUNT(*) FROM admin WHERE key = 'schema_version';");
|
ret = db_get_count("SELECT COUNT(*) FROM admin WHERE key = 'schema_version';");
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user