From fc234b12e5d1b2bd15207fbc9f2cecfd73b42a7b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 20 Sep 2022 15:58:12 -0400 Subject: [PATCH] handle es_info being an empty file --- hub/elastic_sync/service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hub/elastic_sync/service.py b/hub/elastic_sync/service.py index 5044a49..e2ecb57 100644 --- a/hub/elastic_sync/service.py +++ b/hub/elastic_sync/service.py @@ -89,7 +89,10 @@ class ElasticSyncService(BlockchainReaderService): info = {} if os.path.exists(self._es_info_path): with open(self._es_info_path, 'r') as f: - info.update(json.loads(f.read())) + try: + info.update(json.loads(f.read())) + except json.decoder.JSONDecodeError: + self.log.warning('failed to parse es sync status file') self._last_wrote_height = int(info.get('height', 0)) self._last_wrote_block_hash = info.get('block_hash', None)