summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 14445d6618..2ed80a860b 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -478,6 +478,12 @@ bool tagcache_find_index(struct tagcache_search *tcs, const char *filename)
478static bool get_index(int masterfd, int idxid, 478static bool get_index(int masterfd, int idxid,
479 struct index_entry *idx, bool use_ram) 479 struct index_entry *idx, bool use_ram)
480{ 480{
481 if (idxid < 0)
482 {
483 logf("Incorrect idxid: %d", idxid);
484 return false;
485 }
486
481#ifdef HAVE_TC_RAMCACHE 487#ifdef HAVE_TC_RAMCACHE
482 if (stat.ramcache && use_ram) 488 if (stat.ramcache && use_ram)
483 { 489 {
@@ -1005,13 +1011,13 @@ static bool open_files(struct tagcache_search *tcs)
1005} 1011}
1006 1012
1007#define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \ 1013#define TAG_FILENAME_RAM(tcs) ((tcs->type == tag_filename) \
1008 ? (tcs->seek_flags[tcs->seek_list_count] \ 1014 ? (flag & FLAG_DIRCACHE) : 1)
1009 & FLAG_DIRCACHE) : 1)
1010 1015
1011static bool get_next(struct tagcache_search *tcs) 1016static bool get_next(struct tagcache_search *tcs)
1012{ 1017{
1013 static char buf[MAX_PATH]; 1018 static char buf[MAX_PATH];
1014 struct tagfile_entry entry; 1019 struct tagfile_entry entry;
1020 long flag = 0;
1015 1021
1016 if (!tcs->valid || !stat.ready) 1022 if (!tcs->valid || !stat.ready)
1017 return false; 1023 return false;
@@ -1039,6 +1045,7 @@ static bool get_next(struct tagcache_search *tcs)
1039 } 1045 }
1040 1046
1041 tcs->seek_list_count--; 1047 tcs->seek_list_count--;
1048 flag = tcs->seek_flags[tcs->seek_list_count];
1042 1049
1043 /* Seek stream to the correct position and continue to direct fetch. */ 1050 /* Seek stream to the correct position and continue to direct fetch. */
1044 if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs)) 1051 if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
@@ -1076,10 +1083,7 @@ static bool get_next(struct tagcache_search *tcs)
1076 } 1083 }
1077 tcs->entry_count--; 1084 tcs->entry_count--;
1078 1085
1079 if (tagcache_is_unique_tag(tcs->type)) 1086 tcs->result_seek = tcs->position;
1080 tcs->result_seek = tcs->position;
1081 else
1082 tcs->result_seek = tcs->idx_id;
1083 1087
1084# ifdef HAVE_DIRCACHE 1088# ifdef HAVE_DIRCACHE
1085 if (tcs->type == tag_filename) 1089 if (tcs->type == tag_filename)
@@ -1088,6 +1092,8 @@ static bool get_next(struct tagcache_search *tcs)
1088 buf, sizeof buf); 1092 buf, sizeof buf);
1089 tcs->result = buf; 1093 tcs->result = buf;
1090 tcs->result_len = strlen(buf) + 1; 1094 tcs->result_len = strlen(buf) + 1;
1095 tcs->idx_id = FLAG_GET_ATTR(flag);
1096 tcs->ramresult = false;
1091 1097
1092 return true; 1098 return true;
1093 } 1099 }
@@ -1098,6 +1104,7 @@ static bool get_next(struct tagcache_search *tcs)
1098 tcs->result = ep->tag_data; 1104 tcs->result = ep->tag_data;
1099 tcs->result_len = strlen(tcs->result) + 1; 1105 tcs->result_len = strlen(tcs->result) + 1;
1100 tcs->idx_id = ep->idx_id; 1106 tcs->idx_id = ep->idx_id;
1107 tcs->ramresult = true;
1101 1108
1102 return true; 1109 return true;
1103 } 1110 }
@@ -1134,8 +1141,7 @@ static bool get_next(struct tagcache_search *tcs)
1134 tcs->result = buf; 1141 tcs->result = buf;
1135 tcs->result_len = strlen(tcs->result) + 1; 1142 tcs->result_len = strlen(tcs->result) + 1;
1136 tcs->idx_id = entry.idx_id; 1143 tcs->idx_id = entry.idx_id;
1137 if (!tagcache_is_unique_tag(tcs->type)) 1144 tcs->ramresult = false;
1138 tcs->result_seek = tcs->idx_id;
1139 1145
1140 return true; 1146 return true;
1141} 1147}
@@ -3116,6 +3122,7 @@ static bool load_tagcache(void)
3116 } 3122 }
3117 3123
3118 idx->flag |= FLAG_DIRCACHE; 3124 idx->flag |= FLAG_DIRCACHE;
3125 FLAG_SET_ATTR(idx->flag, fe->idx_id);
3119 idx->tag_seek[tag_filename] = (long)dc; 3126 idx->tag_seek[tag_filename] = (long)dc;
3120 } 3127 }
3121 else 3128 else