chg: Properly handle missing HAR

lacus
Raphaël Vinot 2022-09-19 16:16:58 +02:00
parent be3bec1252
commit 1157428d88
1 changed files with 4 additions and 3 deletions

View File

@ -115,8 +115,9 @@ class AsyncCapture(AbstractManager):
with (dirpath / 'error.txt').open('w') as _error: with (dirpath / 'error.txt').open('w') as _error:
json.dump(entries['error'], _error) json.dump(entries['error'], _error)
with (dirpath / '0.har').open('w') as _har: if 'har' in entries:
json.dump(entries['har'], _har) with (dirpath / '0.har').open('w') as _har:
json.dump(entries['har'], _har)
if 'png' in entries and entries['png']: if 'png' in entries and entries['png']:
with (dirpath / '0.png').open('wb') as _img: with (dirpath / '0.png').open('wb') as _img:
@ -133,9 +134,9 @@ class AsyncCapture(AbstractManager):
if 'cookies' in entries and entries['cookies']: if 'cookies' in entries and entries['cookies']:
with (dirpath / '0.cookies.json').open('w') as _cookies: with (dirpath / '0.cookies.json').open('w') as _cookies:
json.dump(entries['cookies'], _cookies) json.dump(entries['cookies'], _cookies)
await self.redis.hset('lookup_dirs', uuid, str(dirpath))
async with self.redis.pipeline() as lazy_cleanup: 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): if queue and await self.redis.zscore('queues', queue):
await lazy_cleanup.zincrby('queues', -1, queue) await lazy_cleanup.zincrby('queues', -1, queue)
await lazy_cleanup.srem('ongoing', uuid) await lazy_cleanup.srem('ongoing', uuid)