fix: Update index for recent captures on every archive

pull/833/head
Raphaël Vinot 2023-11-17 15:47:12 +01:00
parent ce76218657
commit 9a9c4464ed
1 changed files with 7 additions and 1 deletions

View File

@ -65,6 +65,8 @@ class Archiver(AbstractManager):
break break
archiving_done = self._archive() archiving_done = self._archive()
self._load_indexes() self._load_indexes()
if not archiving_done:
self._update_all_capture_indexes(recent_only=True)
if not self.shutdown_requested(): if not self.shutdown_requested():
# This call takes a very long time on MinIO # This call takes a very long time on MinIO
self._update_all_capture_indexes() self._update_all_capture_indexes()
@ -193,7 +195,7 @@ class Archiver(AbstractManager):
return index_file return index_file
def _update_all_capture_indexes(self): def _update_all_capture_indexes(self, *, recent_only: bool=False):
'''Run that after the captures are in the proper directories''' '''Run that after the captures are in the proper directories'''
# Recent captures # Recent captures
self.logger.info('Update recent indexes') self.logger.info('Update recent indexes')
@ -208,6 +210,10 @@ class Archiver(AbstractManager):
break break
self._update_index(directory_to_index) self._update_index(directory_to_index)
self.logger.info('Recent indexes updated') self.logger.info('Recent indexes updated')
if recent_only:
self.logger.info('Only updating recent indexes.')
return
# Archived captures # Archived captures
self.logger.info('Update archives indexes') self.logger.info('Update archives indexes')
for directory_to_index in make_dirs_list(self.archived_captures_dir): for directory_to_index in make_dirs_list(self.archived_captures_dir):