diff options
-rw-r--r-- | apps/tagcache.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 7296650e83..280f45d695 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -427,10 +427,11 @@ bool tagcache_find_index(struct tagcache_search *tcs, const char *filename) | |||
427 | return true; | 427 | return true; |
428 | } | 428 | } |
429 | 429 | ||
430 | static bool get_index(int masterfd, int idxid, struct index_entry *idx) | 430 | static bool get_index(int masterfd, int idxid, |
431 | struct index_entry *idx, bool use_ram) | ||
431 | { | 432 | { |
432 | #ifdef HAVE_TC_RAMCACHE | 433 | #ifdef HAVE_TC_RAMCACHE |
433 | if (stat.ramcache) | 434 | if (stat.ramcache && use_ram) |
434 | { | 435 | { |
435 | if (hdr->indices[idxid].flag & FLAG_DELETED) | 436 | if (hdr->indices[idxid].flag & FLAG_DELETED) |
436 | return false; | 437 | return false; |
@@ -457,14 +458,20 @@ static bool get_index(int masterfd, int idxid, struct index_entry *idx) | |||
457 | 458 | ||
458 | static bool write_index(int masterfd, int idxid, struct index_entry *idx) | 459 | static bool write_index(int masterfd, int idxid, struct index_entry *idx) |
459 | { | 460 | { |
461 | /* We need to exclude all memory only flags & tags when writing to disk. */ | ||
462 | if (idx->flag & FLAG_DIRCACHE) | ||
463 | { | ||
464 | logf("memory only flags!"); | ||
465 | return false; | ||
466 | } | ||
467 | |||
460 | #ifdef HAVE_TC_RAMCACHE | 468 | #ifdef HAVE_TC_RAMCACHE |
461 | if (stat.ramcache) | 469 | if (stat.ramcache) |
470 | { | ||
462 | memcpy(&hdr->indices[idxid], idx, sizeof(struct index_entry)); | 471 | memcpy(&hdr->indices[idxid], idx, sizeof(struct index_entry)); |
472 | } | ||
463 | #endif | 473 | #endif |
464 | 474 | ||
465 | /* We need to exclude all memory only flags when writing on disk. */ | ||
466 | idx->flag = idx->flag & ~(FLAG_DIRCACHE); | ||
467 | |||
468 | lseek(masterfd, idxid * sizeof(struct index_entry) | 475 | lseek(masterfd, idxid * sizeof(struct index_entry) |
469 | + sizeof(struct master_header), SEEK_SET); | 476 | + sizeof(struct master_header), SEEK_SET); |
470 | if (write(masterfd, idx, sizeof(struct index_entry)) != | 477 | if (write(masterfd, idx, sizeof(struct index_entry)) != |
@@ -514,7 +521,7 @@ long tagcache_get_numeric(const struct tagcache_search *tcs, int tag) | |||
514 | if (!tagcache_is_numeric_tag(tag)) | 521 | if (!tagcache_is_numeric_tag(tag)) |
515 | return -1; | 522 | return -1; |
516 | 523 | ||
517 | if (!get_index(tcs->masterfd, tcs->idx_id, &idx)) | 524 | if (!get_index(tcs->masterfd, tcs->idx_id, &idx, true)) |
518 | return -2; | 525 | return -2; |
519 | 526 | ||
520 | return check_virtual_tags(tag, &idx); | 527 | return check_virtual_tags(tag, &idx); |
@@ -1018,7 +1025,7 @@ bool tagcache_retrieve(struct tagcache_search *tcs, int idxid, | |||
1018 | struct index_entry idx; | 1025 | struct index_entry idx; |
1019 | long seek; | 1026 | long seek; |
1020 | 1027 | ||
1021 | if (!get_index(tcs->masterfd, idxid, &idx)) | 1028 | if (!get_index(tcs->masterfd, idxid, &idx, true)) |
1022 | return false; | 1029 | return false; |
1023 | 1030 | ||
1024 | seek = idx.tag_seek[tcs->type]; | 1031 | seek = idx.tag_seek[tcs->type]; |
@@ -2239,7 +2246,7 @@ static bool modify_numeric_entry(int masterfd, int idx_id, int tag, long data) | |||
2239 | if (!tagcache_is_numeric_tag(tag)) | 2246 | if (!tagcache_is_numeric_tag(tag)) |
2240 | return false; | 2247 | return false; |
2241 | 2248 | ||
2242 | if (!get_index(masterfd, idx_id, &idx)) | 2249 | if (!get_index(masterfd, idx_id, &idx, false)) |
2243 | return false; | 2250 | return false; |
2244 | 2251 | ||
2245 | idx.tag_seek[tag] = data; | 2252 | idx.tag_seek[tag] = data; |
@@ -2387,7 +2394,7 @@ static bool parse_changelog_line(int masterfd, const char *buf) | |||
2387 | return false; | 2394 | return false; |
2388 | } | 2395 | } |
2389 | 2396 | ||
2390 | if (!get_index(masterfd, idx_id, &idx)) | 2397 | if (!get_index(masterfd, idx_id, &idx, false)) |
2391 | { | 2398 | { |
2392 | logf("failed to retrieve index entry"); | 2399 | logf("failed to retrieve index entry"); |
2393 | return false; | 2400 | return false; |