summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/db.c b/db.c
index ceac924..d2b16be 100644
--- a/db.c
+++ b/db.c
@@ -278,10 +278,33 @@ sqlite_uint64 db_get_wallpaper(const char *path) {
return 0;
}
+static void db_clear_wall_tags(sqlite_uint64 wallid) {
+ sqlite3_stmt *stmt;
+ int rc;
+
+ rc = sqlite3_prepare_v2(db, "DELETE FROM walltags WHERE wallid = ?", -1, &stmt, NULL);
+
+ if(rc != SQLITE_OK) {
+ return;
+ }
+
+ rc = sqlite3_bind_int64(stmt, 1, wallid);
+ if(rc != SQLITE_OK) {
+ sqlite3_finalize(stmt);
+ return;
+ }
+
+ sqlite3_step(stmt);
+
+ sqlite3_finalize(stmt);
+}
+
int db_remove_wallpaper(sqlite_uint64 id) {
sqlite3_stmt *stmt;
int rc;
+ db_clear_wall_tags(id);
+
rc = sqlite3_prepare_v2(db, "DELETE FROM wallpaper WHERE id = ?", -1, &stmt, NULL);
if(rc != SQLITE_OK) {
return 0;