chg: Always make sure the lock file is removed even if building the tree fails

pull/209/head
Raphaël Vinot 2021-05-28 17:28:26 -07:00
parent 7f221c8b9e
commit 17af2df5cd
1 changed files with 11 additions and 10 deletions

View File

@ -194,7 +194,7 @@ class Lookyloo():
raise NoValidHarFile(e.message)
except RecursionError as e:
raise NoValidHarFile(f'Tree too deep, probably a recursive refresh: {e}.\n Append /export to the URL to get the files.')
else:
with pickle_file.open('wb') as _p:
# Some pickles require a pretty high recursion limit, this kindof fixes it.
# If the capture is really broken (generally a refresh to self), the capture
@ -203,6 +203,7 @@ class Lookyloo():
sys.setrecursionlimit(int(default_recursion_limit * 1.1))
pickle.dump(ct, _p)
sys.setrecursionlimit(default_recursion_limit)
finally:
lock_file.unlink(missing_ok=True)
return ct