From d6af04ba915063ae7b646e311bca31a89e68d298 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 28 May 2006 09:59:24 +0000 Subject: Load uniqued tags correctly at commit (should fix duplicates). Try first dircache buffer as it's usually bigger. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10003 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'apps/tagcache.c') diff --git a/apps/tagcache.c b/apps/tagcache.c index f4e139aafa..98beba9b58 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -1495,7 +1495,8 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) * table when the index gets resorted. */ tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH - + TAGFILE_MAX_ENTRIES, entry.idx_id, false); + + TAGFILE_MAX_ENTRIES, entry.idx_id, + tagcache_is_unique_tag(index_type)); yield(); } logf("done"); @@ -1813,6 +1814,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) if (index_type != tag_filename) h->datasize += tch.datasize; + logf("s:%d/%d/%d", index_type, tch.datasize, h->datasize); error_exit: close(fd); @@ -1862,23 +1864,25 @@ static bool commit(void) } /* Try to steal every buffer we can :) */ -#ifdef HAVE_TC_RAMCACHE - if (tempbuf_size == 0 && stat.ramcache_allocated > 0) - { - stat.ramcache = false; - tempbuf = (char *)(hdr + 1); - tempbuf_size = stat.ramcache_allocated - sizeof(struct ramcache_header); - } -#endif - #ifdef HAVE_DIRCACHE if (tempbuf_size == 0) { /* Try to steal the dircache buffer. */ tempbuf = dircache_steal_buffer(&tempbuf_size); + tempbuf_size &= ~0x03; } #endif +#ifdef HAVE_TC_RAMCACHE + if (tempbuf_size == 0 && stat.ramcache_allocated > 0) + { + stat.ramcache = false; + tempbuf = (char *)(hdr + 1); + tempbuf_size = stat.ramcache_allocated - sizeof(struct ramcache_header) - 128; + tempbuf_size &= ~0x03; + } +#endif + /* And finally fail if there are no buffers available. */ if (tempbuf_size == 0) { @@ -1909,6 +1913,7 @@ static bool commit(void) ret = build_index(i, &header, tmpfd); if (ret <= 0) { + close(tmpfd); logf("tagcache failed init"); if (ret < 0) remove_files(); @@ -2176,7 +2181,9 @@ static bool load_tagcache(void) bytesleft -= sizeof(struct tagfile_entry) + fe->tag_length; if (bytesleft < 0) { - logf("too big tagcache."); + logf("too big tagcache #2"); + logf("tl: %d", fe->tag_length); + logf("bl: %d", bytesleft); close(fd); return false; } -- cgit v1.2.3