summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index afe55f18a2..d4ec1078d8 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -1313,18 +1313,7 @@ static bool get_next(struct tagcache_search *tcs)
1313 1313
1314 tcs->seek_list_count--; 1314 tcs->seek_list_count--;
1315 flag = tcs->seek_flags[tcs->seek_list_count]; 1315 flag = tcs->seek_flags[tcs->seek_list_count];
1316 1316 tcs->position = tcs->seek_list[tcs->seek_list_count];
1317 /* Seek stream to the correct position and continue to direct fetch. */
1318 if ((!tcs->ramsearch || !TAG_FILENAME_RAM(tcs))
1319 && !TAGCACHE_IS_NUMERIC(tcs->type))
1320 {
1321 if (!open_files(tcs, tcs->type))
1322 return false;
1323
1324 lseek(tcs->idxfd[tcs->type], tcs->seek_list[tcs->seek_list_count], SEEK_SET);
1325 }
1326 else
1327 tcs->position = tcs->seek_list[tcs->seek_list_count];
1328 } 1317 }
1329 1318
1330 if (TAGCACHE_IS_NUMERIC(tcs->type)) 1319 if (TAGCACHE_IS_NUMERIC(tcs->type))
@@ -1374,20 +1363,21 @@ static bool get_next(struct tagcache_search *tcs)
1374 1363
1375 return true; 1364 return true;
1376 } 1365 }
1377 else
1378#endif 1366#endif
1367
1368 if (!open_files(tcs, tcs->type))
1369 return false;
1370
1371 /* Seek stream to the correct position and continue to direct fetch. */
1372 lseek(tcs->idxfd[tcs->type], tcs->position, SEEK_SET);
1373 tcs->result_seek = tcs->position;
1374
1375 if (ecread(tcs->idxfd[tcs->type], &entry, 1,
1376 tagfile_entry_ec, tc_stat.econ) != sizeof(struct tagfile_entry))
1379 { 1377 {
1380 if (!open_files(tcs, tcs->type)) 1378 /* End of data. */
1381 return false; 1379 tcs->valid = false;
1382 1380 return false;
1383 tcs->result_seek = lseek(tcs->idxfd[tcs->type], 0, SEEK_CUR);
1384 if (ecread(tcs->idxfd[tcs->type], &entry, 1,
1385 tagfile_entry_ec, tc_stat.econ) != sizeof(struct tagfile_entry))
1386 {
1387 /* End of data. */
1388 tcs->valid = false;
1389 return false;
1390 }
1391 } 1381 }
1392 1382
1393 if (entry.tag_length > (long)sizeof(buf)) 1383 if (entry.tag_length > (long)sizeof(buf))
@@ -1404,6 +1394,11 @@ static bool get_next(struct tagcache_search *tcs)
1404 return false; 1394 return false;
1405 } 1395 }
1406 1396
1397 /**
1398 Update the position for the next read (this may be overridden
1399 if filters or clauses are being used).
1400 */
1401 tcs->position += sizeof(struct tagfile_entry) + entry.tag_length;
1407 tcs->result = buf; 1402 tcs->result = buf;
1408 tcs->result_len = strlen(tcs->result) + 1; 1403 tcs->result_len = strlen(tcs->result) + 1;
1409 tcs->idx_id = entry.idx_id; 1404 tcs->idx_id = entry.idx_id;