diff options
| author | Michael Hohmuth <sideral@rockbox.org> | 2011-08-04 23:03:43 +0000 |
|---|---|---|
| committer | Michael Hohmuth <sideral@rockbox.org> | 2011-08-04 23:03:43 +0000 |
| commit | c027dc20be013dc065d8e847f9048c39606e183d (patch) | |
| tree | a732fac40eacf495ea130c92b8658f62eef20c2e | |
| parent | fa81cdc61a58848708481322812c80c62f0b3bf6 (diff) | |
| download | rockbox-c027dc20be013dc065d8e847f9048c39606e183d.zip rockbox-c027dc20be013dc065d8e847f9048c39606e183d.tar.gz rockbox-c027dc20be013dc065d8e847f9048c39606e183d.tar.bz2 rockbox-c027dc20be013dc065d8e847f9048c39606e183d.tar.xz | |
Database: Bug fix: The filename seek index is invalid if FLAG_DIRCACHE
is set on a database entry and the dircache went offline. In this
case, retrieve() and get_next() need to abort and take the ramcache
offline as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30255 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/tagcache.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 1889237..6aa7709 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -721,12 +721,24 @@ static bool retrieve(struct tagcache_search *tcs, struct index_entry *idx, struct tagfile_entry *ep; # ifdef HAVE_DIRCACHE - if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE) - && is_dircache_intact()) + if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE)) { /* for tag_filename, seek is a dircache index */ - dircache_copy_path(seek, buf, size); - return true; + if (is_dircache_intact()) + { + dircache_copy_path(seek, buf, size); + return true; + } + else + { + /* The seek is useless now, there's nothing we can return. */ + logf("retrieve: dircache gone, cannot read file name"); + tagcache_unload_ramcache(); + // XXX do this when there's a way to not trigger an + // update before reloading: + // tagcache_start_scan(); + return false; + } } else # endif @@ -1496,15 +1508,28 @@ static bool get_next(struct tagcache_search *tcs) { #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) - if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE) - && is_dircache_intact()) + if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE)) { - size_t len = dircache_copy_path(tcs->position, buf, sizeof buf); - tcs->result_len = len + 1; - tcs->result = buf; - tcs->ramresult = false; + if (is_dircache_intact()) + { + size_t len = dircache_copy_path(tcs->position, buf, sizeof buf); + tcs->result_len = len + 1; + tcs->result = buf; + tcs->ramresult = false; - return true; + return true; + } + else + { + /* The seek is useless now, there's nothing we can return. */ + logf("get_next: dircache gone, cannot read file name"); + tagcache_unload_ramcache(); + // XXX do this when there's a way to not trigger an + // update before reloading: + // tagcache_start_scan(); + tcs->valid = false; + return false; + } } else #endif |