[db] db_pl_delete_bypath() must also delete disabled playlists

Otherwise we end up with a bunch of disabled playlists in the db.
This commit is contained in:
ejurgensen 2020-03-29 00:33:44 +01:00
parent 5bd32135ee
commit f61dfa0529
2 changed files with 9 additions and 2 deletions

View File

@ -1664,10 +1664,14 @@ db_build_query_clause(struct query_params *qp)
else else
qc->group = sqlite3_mprintf(""); qc->group = sqlite3_mprintf("");
if (qp->filter) if (qp->filter && !qp->with_disabled)
qc->where = sqlite3_mprintf("WHERE f.disabled = 0 AND %s", qp->filter); qc->where = sqlite3_mprintf("WHERE f.disabled = 0 AND %s", qp->filter);
else else if (!qp->with_disabled)
qc->where = sqlite3_mprintf("WHERE f.disabled = 0"); qc->where = sqlite3_mprintf("WHERE f.disabled = 0");
else if (qp->filter)
qc->where = sqlite3_mprintf("WHERE %s", qp->filter);
else
qc->where = sqlite3_mprintf("");
if (qp->having && (qp->type & (Q_GROUP_ALBUMS | Q_GROUP_ARTISTS))) if (qp->having && (qp->type & (Q_GROUP_ALBUMS | Q_GROUP_ARTISTS)))
qc->having = sqlite3_mprintf("HAVING %s", qp->having); qc->having = sqlite3_mprintf("HAVING %s", qp->having);
@ -3653,6 +3657,7 @@ db_pl_delete_bypath(const char *path)
memset(&qp, 0, sizeof(struct query_params)); memset(&qp, 0, sizeof(struct query_params));
qp.type = Q_PL; qp.type = Q_PL;
qp.with_disabled = 1;
CHECK_NULL(L_DB, qp.filter = db_mprintf("path = '%q'", path)); CHECK_NULL(L_DB, qp.filter = db_mprintf("path = '%q'", path));
ret = db_query_start(&qp); ret = db_query_start(&qp);

View File

@ -99,6 +99,8 @@ struct query_params {
char *filter; char *filter;
int with_disabled;
/* Query results, filled in by query_start */ /* Query results, filled in by query_start */
int results; int results;