From 133e971edc4e652939e65cca5f9f82c0612afef3 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Sun, 9 Jan 2005 20:02:01 +0000 Subject: [PATCH] Fixes for the "Doesn't actually delete stuff on rescan" bug. Thanks to Roger Mundt for the logs and documentation to track this down. --- CREDITS | 4 ++++ src/db-gdbm.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index e9f15cc1..c1e1ea62 100644 --- a/CREDITS +++ b/CREDITS @@ -62,3 +62,7 @@ Stephen Rubner Ciamac Moallemi * gzip content-encoding +Roger Mundt + * troubleshooting and debugging help + + diff --git a/src/db-gdbm.c b/src/db-gdbm.c index 6f7471cb..c537b8d6 100644 --- a/src/db-gdbm.c +++ b/src/db-gdbm.c @@ -498,13 +498,23 @@ int db_start_initial_update(void) { */ int db_end_initial_update(void) { const void *val; + unsigned long int oldval; + unsigned long int *oldptr; + DB_PLAYLIST *current,*last; DB_PLAYLISTENTRY *pple; DPRINTF(E_DBG,L_DB|L_SCAN,"Initial update over. Removing stale items\n"); - for(val=rblookup(RB_LUFIRST,NULL,db_removed); val != NULL; - val=rblookup(RB_LUNEXT,val,db_removed)) { - db_delete(*((int*)val)); + val=rblookup(RB_LUFIRST,NULL,db_removed); + + while(val) { + oldval=(*((int*)val)); + oldptr=(unsigned long int*)rbdelete((void*)&oldval,db_removed); + if(oldptr) + free(oldptr); + db_delete(oldval); + + val=rblookup(RB_LUFIRST,NULL,db_removed); } DPRINTF(E_DBG,L_DB|L_SCAN,"Done removing stale items\n");