diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2009-04-15 06:46:25 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2009-04-15 06:46:25 +0000 |
commit | a1614508221a2ce453e1ac306293ba981eb41330 (patch) | |
tree | 0ebb74b6b1fe707b7e0fbdf398753f85c91b795b | |
parent | bf37ecb6b8fe46e203db844553f65d0a1ba02d95 (diff) | |
download | rockbox-a1614508221a2ce453e1ac306293ba981eb41330.tar.gz rockbox-a1614508221a2ce453e1ac306293ba981eb41330.zip |
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
-rw-r--r-- | apps/tagcache.c | 11 |
1 files 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) | |||
1491 | 1491 | ||
1492 | myhdr.serial = current_tcmh.serial; | 1492 | myhdr.serial = current_tcmh.serial; |
1493 | myhdr.commitid = current_tcmh.commitid; | 1493 | myhdr.commitid = current_tcmh.commitid; |
1494 | myhdr.dirty = current_tcmh.dirty; | ||
1494 | 1495 | ||
1495 | /* Write it back */ | 1496 | /* Write it back */ |
1496 | lseek(fd, 0, SEEK_SET); | 1497 | lseek(fd, 0, SEEK_SET); |
@@ -1502,6 +1503,7 @@ static bool update_master_header(void) | |||
1502 | { | 1503 | { |
1503 | hdr->h.serial = current_tcmh.serial; | 1504 | hdr->h.serial = current_tcmh.serial; |
1504 | hdr->h.commitid = current_tcmh.commitid; | 1505 | hdr->h.commitid = current_tcmh.commitid; |
1506 | hdr->h.dirty = current_tcmh.dirty; | ||
1505 | } | 1507 | } |
1506 | #endif | 1508 | #endif |
1507 | 1509 | ||
@@ -2902,10 +2904,9 @@ static bool commit(void) | |||
2902 | { | 2904 | { |
2903 | close(tmpfd); | 2905 | close(tmpfd); |
2904 | logf("tagcache failed init"); | 2906 | logf("tagcache failed init"); |
2905 | if (ret < 0) | 2907 | if (ret == 0) |
2906 | remove_files(); | ||
2907 | else | ||
2908 | tc_stat.commit_delayed = true; | 2908 | tc_stat.commit_delayed = true; |
2909 | |||
2909 | tc_stat.commit_step = 0; | 2910 | tc_stat.commit_step = 0; |
2910 | read_lock--; | 2911 | read_lock--; |
2911 | return false; | 2912 | return false; |
@@ -2916,13 +2917,14 @@ static bool commit(void) | |||
2916 | { | 2917 | { |
2917 | logf("Failure to commit numeric indices"); | 2918 | logf("Failure to commit numeric indices"); |
2918 | close(tmpfd); | 2919 | close(tmpfd); |
2919 | remove_files(); | ||
2920 | tc_stat.commit_step = 0; | 2920 | tc_stat.commit_step = 0; |
2921 | read_lock--; | 2921 | read_lock--; |
2922 | return false; | 2922 | return false; |
2923 | } | 2923 | } |
2924 | 2924 | ||
2925 | close(tmpfd); | 2925 | close(tmpfd); |
2926 | remove(TAGCACHE_FILE_TEMP); | ||
2927 | |||
2926 | tc_stat.commit_step = 0; | 2928 | tc_stat.commit_step = 0; |
2927 | 2929 | ||
2928 | /* Update the master index headers. */ | 2930 | /* Update the master index headers. */ |
@@ -2944,7 +2946,6 @@ static bool commit(void) | |||
2944 | close(masterfd); | 2946 | close(masterfd); |
2945 | 2947 | ||
2946 | logf("tagcache committed"); | 2948 | logf("tagcache committed"); |
2947 | remove(TAGCACHE_FILE_TEMP); | ||
2948 | tc_stat.ready = check_all_headers(); | 2949 | tc_stat.ready = check_all_headers(); |
2949 | tc_stat.readyvalid = true; | 2950 | tc_stat.readyvalid = true; |
2950 | 2951 | ||