From a1614508221a2ce453e1ac306293ba981eb41330 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Wed, 15 Apr 2009 06:46:25 +0000 Subject: Handle the DB dirty flag correctly. Now a broken DB should stay disabled. Also don't remove broken files automatically. Should improve (or even fix) the duplicate entry issue seen in FS#8414 when the problem is caused by the player shutting down in the middle of a DB commit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20710 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/tagcache.c b/apps/tagcache.c index 2b2881a9b8..84e8875968 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -1491,6 +1491,7 @@ static bool update_master_header(void) myhdr.serial = current_tcmh.serial; myhdr.commitid = current_tcmh.commitid; + myhdr.dirty = current_tcmh.dirty; /* Write it back */ lseek(fd, 0, SEEK_SET); @@ -1502,6 +1503,7 @@ static bool update_master_header(void) { hdr->h.serial = current_tcmh.serial; hdr->h.commitid = current_tcmh.commitid; + hdr->h.dirty = current_tcmh.dirty; } #endif @@ -2902,10 +2904,9 @@ static bool commit(void) { close(tmpfd); logf("tagcache failed init"); - if (ret < 0) - remove_files(); - else + if (ret == 0) tc_stat.commit_delayed = true; + tc_stat.commit_step = 0; read_lock--; return false; @@ -2916,13 +2917,14 @@ static bool commit(void) { logf("Failure to commit numeric indices"); close(tmpfd); - remove_files(); tc_stat.commit_step = 0; read_lock--; return false; } close(tmpfd); + remove(TAGCACHE_FILE_TEMP); + tc_stat.commit_step = 0; /* Update the master index headers. */ @@ -2944,7 +2946,6 @@ static bool commit(void) close(masterfd); logf("tagcache committed"); - remove(TAGCACHE_FILE_TEMP); tc_stat.ready = check_all_headers(); tc_stat.readyvalid = true; -- cgit v1.2.3