1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Hohmuth 2011-08-04 23:03:43 +00:00
parent fa81cdc61a
commit c027dc20be

View file

@ -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