forked from len0rd/rockbox
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
This commit is contained in:
parent
59953140a7
commit
d6af04ba91
1 changed files with 18 additions and 11 deletions
|
|
@ -1495,7 +1495,8 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
* table when the index gets resorted.
|
* table when the index gets resorted.
|
||||||
*/
|
*/
|
||||||
tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH
|
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();
|
yield();
|
||||||
}
|
}
|
||||||
logf("done");
|
logf("done");
|
||||||
|
|
@ -1813,6 +1814,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
|
|
||||||
if (index_type != tag_filename)
|
if (index_type != tag_filename)
|
||||||
h->datasize += tch.datasize;
|
h->datasize += tch.datasize;
|
||||||
|
logf("s:%d/%d/%d", index_type, tch.datasize, h->datasize);
|
||||||
error_exit:
|
error_exit:
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
@ -1862,23 +1864,25 @@ static bool commit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to steal every buffer we can :) */
|
/* 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
|
#ifdef HAVE_DIRCACHE
|
||||||
if (tempbuf_size == 0)
|
if (tempbuf_size == 0)
|
||||||
{
|
{
|
||||||
/* Try to steal the dircache buffer. */
|
/* Try to steal the dircache buffer. */
|
||||||
tempbuf = dircache_steal_buffer(&tempbuf_size);
|
tempbuf = dircache_steal_buffer(&tempbuf_size);
|
||||||
|
tempbuf_size &= ~0x03;
|
||||||
}
|
}
|
||||||
#endif
|
#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. */
|
/* And finally fail if there are no buffers available. */
|
||||||
if (tempbuf_size == 0)
|
if (tempbuf_size == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1909,6 +1913,7 @@ static bool commit(void)
|
||||||
ret = build_index(i, &header, tmpfd);
|
ret = build_index(i, &header, tmpfd);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
|
close(tmpfd);
|
||||||
logf("tagcache failed init");
|
logf("tagcache failed init");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
remove_files();
|
remove_files();
|
||||||
|
|
@ -2176,7 +2181,9 @@ static bool load_tagcache(void)
|
||||||
bytesleft -= sizeof(struct tagfile_entry) + fe->tag_length;
|
bytesleft -= sizeof(struct tagfile_entry) + fe->tag_length;
|
||||||
if (bytesleft < 0)
|
if (bytesleft < 0)
|
||||||
{
|
{
|
||||||
logf("too big tagcache.");
|
logf("too big tagcache #2");
|
||||||
|
logf("tl: %d", fe->tag_length);
|
||||||
|
logf("bl: %d", bytesleft);
|
||||||
close(fd);
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue