summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/tagcache.c47
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