diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-05-28 09:59:24 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-05-28 09:59:24 +0000 |
commit | d6af04ba915063ae7b646e311bca31a89e68d298 (patch) | |
tree | 7275c8cf12bfd0d3361c8e89a006909ac8ee08d7 /apps/tagcache.c | |
parent | 59953140a7195ae66f866dd2034f77a1adf92605 (diff) | |
download | rockbox-d6af04ba915063ae7b646e311bca31a89e68d298.tar.gz rockbox-d6af04ba915063ae7b646e311bca31a89e68d298.zip |
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
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 29 |
1 files changed, 18 insertions, 11 deletions
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) | |||
1495 | * table when the index gets resorted. | 1495 | * table when the index gets resorted. |
1496 | */ | 1496 | */ |
1497 | tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH | 1497 | tempbuf_insert(buf, loc/TAGFILE_ENTRY_CHUNK_LENGTH |
1498 | + TAGFILE_MAX_ENTRIES, entry.idx_id, false); | 1498 | + TAGFILE_MAX_ENTRIES, entry.idx_id, |
1499 | tagcache_is_unique_tag(index_type)); | ||
1499 | yield(); | 1500 | yield(); |
1500 | } | 1501 | } |
1501 | logf("done"); | 1502 | logf("done"); |
@@ -1813,6 +1814,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
1813 | 1814 | ||
1814 | if (index_type != tag_filename) | 1815 | if (index_type != tag_filename) |
1815 | h->datasize += tch.datasize; | 1816 | h->datasize += tch.datasize; |
1817 | logf("s:%d/%d/%d", index_type, tch.datasize, h->datasize); | ||
1816 | error_exit: | 1818 | error_exit: |
1817 | 1819 | ||
1818 | close(fd); | 1820 | close(fd); |
@@ -1862,23 +1864,25 @@ static bool commit(void) | |||
1862 | } | 1864 | } |
1863 | 1865 | ||
1864 | /* Try to steal every buffer we can :) */ | 1866 | /* Try to steal every buffer we can :) */ |
1865 | #ifdef HAVE_TC_RAMCACHE | ||
1866 | if (tempbuf_size == 0 && stat.ramcache_allocated > 0) | ||
1867 | { | ||
1868 | stat.ramcache = false; | ||
1869 | tempbuf = (char *)(hdr + 1); | ||
1870 | tempbuf_size = stat.ramcache_allocated - sizeof(struct ramcache_header); | ||
1871 | } | ||
1872 | #endif | ||
1873 | |||
1874 | #ifdef HAVE_DIRCACHE | 1867 | #ifdef HAVE_DIRCACHE |
1875 | if (tempbuf_size == 0) | 1868 | if (tempbuf_size == 0) |
1876 | { | 1869 | { |
1877 | /* Try to steal the dircache buffer. */ | 1870 | /* Try to steal the dircache buffer. */ |
1878 | tempbuf = dircache_steal_buffer(&tempbuf_size); | 1871 | tempbuf = dircache_steal_buffer(&tempbuf_size); |
1872 | tempbuf_size &= ~0x03; | ||
1879 | } | 1873 | } |
1880 | #endif | 1874 | #endif |
1881 | 1875 | ||
1876 | #ifdef HAVE_TC_RAMCACHE | ||
1877 | if (tempbuf_size == 0 && stat.ramcache_allocated > 0) | ||
1878 | { | ||
1879 | stat.ramcache = false; | ||
1880 | tempbuf = (char *)(hdr + 1); | ||
1881 | tempbuf_size = stat.ramcache_allocated - sizeof(struct ramcache_header) - 128; | ||
1882 | tempbuf_size &= ~0x03; | ||
1883 | } | ||
1884 | #endif | ||
1885 | |||
1882 | /* And finally fail if there are no buffers available. */ | 1886 | /* And finally fail if there are no buffers available. */ |
1883 | if (tempbuf_size == 0) | 1887 | if (tempbuf_size == 0) |
1884 | { | 1888 | { |
@@ -1909,6 +1913,7 @@ static bool commit(void) | |||
1909 | ret = build_index(i, &header, tmpfd); | 1913 | ret = build_index(i, &header, tmpfd); |
1910 | if (ret <= 0) | 1914 | if (ret <= 0) |
1911 | { | 1915 | { |
1916 | close(tmpfd); | ||
1912 | logf("tagcache failed init"); | 1917 | logf("tagcache failed init"); |
1913 | if (ret < 0) | 1918 | if (ret < 0) |
1914 | remove_files(); | 1919 | remove_files(); |
@@ -2176,7 +2181,9 @@ static bool load_tagcache(void) | |||
2176 | bytesleft -= sizeof(struct tagfile_entry) + fe->tag_length; | 2181 | bytesleft -= sizeof(struct tagfile_entry) + fe->tag_length; |
2177 | if (bytesleft < 0) | 2182 | if (bytesleft < 0) |
2178 | { | 2183 | { |
2179 | logf("too big tagcache."); | 2184 | logf("too big tagcache #2"); |
2185 | logf("tl: %d", fe->tag_length); | ||
2186 | logf("bl: %d", bytesleft); | ||
2180 | close(fd); | 2187 | close(fd); |
2181 | return false; | 2188 | return false; |
2182 | } | 2189 | } |