save cookies to tempfile, then rename

avoids wiping the cookies file if the disk is full
This commit is contained in:
Luc Ritchie
2023-04-24 00:01:51 -04:00
parent 28d60e3546
commit 7dd79eee93

View File

@@ -431,8 +431,9 @@ class Extractor():
return
try:
with open(path, "w") as fp:
with open(path + ".tmp", "w") as fp:
util.cookiestxt_store(fp, self.cookies)
os.replace(path + ".tmp", path)
except OSError as exc:
self.log.warning("cookies: %s", exc)