mirror of https://github.com/CIRCL/lookyloo
chg: Allow to stop indexing before all the captures are indexed
parent
90525cfff2
commit
7a37751447
|
@ -40,16 +40,21 @@ class BackgroundIndexer(AbstractManager):
|
||||||
return None
|
return None
|
||||||
self.logger.info(f'Check {self.script_name}...')
|
self.logger.info(f'Check {self.script_name}...')
|
||||||
# NOTE: only get the non-archived captures for now.
|
# NOTE: only get the non-archived captures for now.
|
||||||
|
__counter_shutdown = 0
|
||||||
for uuid, d in self.redis.hscan_iter('lookup_dirs'):
|
for uuid, d in self.redis.hscan_iter('lookup_dirs'):
|
||||||
if not self.full_indexer:
|
if not self.full_indexer:
|
||||||
# If we're not running the full indexer, check if the capture should be indexed.
|
# If we're not running the full indexer, check if the capture should be indexed.
|
||||||
if self.is_public_instance and self.redis.hexists(d, 'no_index'):
|
if self.is_public_instance and self.redis.hexists(d, 'no_index'):
|
||||||
# Capture unindexed
|
# Capture unindexed
|
||||||
continue
|
continue
|
||||||
|
__counter_shutdown += 1
|
||||||
self.indexing.index_capture(uuid, Path(d))
|
self.indexing.index_capture(uuid, Path(d))
|
||||||
self.indexing.indexing_done()
|
if __counter_shutdown % 10 and self.shutdown_requested():
|
||||||
|
self.logger.warning('Shutdown requested, breaking.')
|
||||||
|
break
|
||||||
|
else:
|
||||||
self.logger.info('... done.')
|
self.logger.info('... done.')
|
||||||
|
self.indexing.indexing_done()
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|
Loading…
Reference in New Issue