From 1157428d8898e6c19ae3c9af4a95fa9a104fd2a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 19 Sep 2022 16:16:58 +0200 Subject: [PATCH] chg: Properly handle missing HAR --- bin/async_capture.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/async_capture.py b/bin/async_capture.py index f8690c7..c654d3e 100755 --- a/bin/async_capture.py +++ b/bin/async_capture.py @@ -115,8 +115,9 @@ class AsyncCapture(AbstractManager): with (dirpath / 'error.txt').open('w') as _error: json.dump(entries['error'], _error) - with (dirpath / '0.har').open('w') as _har: - json.dump(entries['har'], _har) + if 'har' in entries: + with (dirpath / '0.har').open('w') as _har: + json.dump(entries['har'], _har) if 'png' in entries and entries['png']: with (dirpath / '0.png').open('wb') as _img: @@ -133,9 +134,9 @@ class AsyncCapture(AbstractManager): if 'cookies' in entries and entries['cookies']: with (dirpath / '0.cookies.json').open('w') as _cookies: json.dump(entries['cookies'], _cookies) - await self.redis.hset('lookup_dirs', uuid, str(dirpath)) async with self.redis.pipeline() as lazy_cleanup: + await lazy_cleanup.hset('lookup_dirs', uuid, str(dirpath)) if queue and await self.redis.zscore('queues', queue): await lazy_cleanup.zincrby('queues', -1, queue) await lazy_cleanup.srem('ongoing', uuid)