summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hohmuth <sideral@rockbox.org>2011-08-04 23:22:26 +0000
committerMichael Hohmuth <sideral@rockbox.org>2011-08-04 23:22:26 +0000
commit1bb10529252786e34ccd3db3e78d060bea5e9343 (patch)
tree92cc175a5b610347c6bd8fc278a90cc9da1162d8
parent211c082d91cbdaf8b1953f263e687c2a8f66148c (diff)
downloadrockbox-1bb10529252786e34ccd3db3e78d060bea5e9343.tar.gz
rockbox-1bb10529252786e34ccd3db3e78d060bea5e9343.zip
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/branches/v3_9@30257 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tagcache.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 9f4769258f..91347c048e 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -719,12 +719,25 @@ static bool retrieve(struct tagcache_search *tcs, struct index_entry *idx,
719 struct tagfile_entry *ep; 719 struct tagfile_entry *ep;
720 720
721# ifdef HAVE_DIRCACHE 721# ifdef HAVE_DIRCACHE
722 if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE) 722 if (tag == tag_filename && (idx->flag & FLAG_DIRCACHE))
723 && is_dircache_intact())
724 { 723 {
725 dircache_copy_path((struct dircache_entry *)seek, 724 /* for tag_filename, seek is a dircache index */
726 buf, size); 725 if (is_dircache_intact())
727 return true; 726 {
727 dircache_copy_path((struct dircache_entry *)seek,
728 buf, size);
729 return true;
730 }
731 else
732 {
733 /* The seek is useless now, there's nothing we can return. */
734 logf("retrieve: dircache gone, cannot read file name");
735 tagcache_unload_ramcache();
736 // XXX do this when there's a way to not trigger an
737 // update before reloading:
738 // tagcache_start_scan();
739 return false;
740 }
728 } 741 }
729 else 742 else
730# endif 743# endif
@@ -1477,16 +1490,29 @@ static bool get_next(struct tagcache_search *tcs)
1477 { 1490 {
1478 1491
1479#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 1492#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
1480 if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE) 1493 if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE))
1481 && is_dircache_intact())
1482 { 1494 {
1483 dircache_copy_path((struct dircache_entry *)tcs->position, 1495 if (is_dircache_intact())
1484 buf, sizeof buf); 1496 {
1485 tcs->result = buf; 1497 dircache_copy_path((struct dircache_entry *)tcs->position,
1486 tcs->result_len = strlen(buf) + 1; 1498 buf, sizeof buf);
1487 tcs->ramresult = false; 1499 tcs->result = buf;
1500 tcs->result_len = strlen(buf) + 1;
1501 tcs->ramresult = false;
1488 1502
1489 return true; 1503 return true;
1504 }
1505 else
1506 {
1507 /* The seek is useless now, there's nothing we can return. */
1508 logf("get_next: dircache gone, cannot read file name");
1509 tagcache_unload_ramcache();
1510 // XXX do this when there's a way to not trigger an
1511 // update before reloading:
1512 // tagcache_start_scan();
1513 tcs->valid = false;
1514 return false;
1515 }
1490 } 1516 }
1491 else 1517 else
1492#endif 1518#endif