anti-cf 1.1.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: anti_cf
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Anti-CloudFlare package
5
5
  License: MIT
6
6
  Author: Steven Van Ingelgem
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "anti_cf"
3
- version = "1.1.0"
3
+ version = "1.1.1"
4
4
  description = "Anti-CloudFlare package"
5
5
  authors = ["Steven Van Ingelgem <steven@vaningelgem.be>"]
6
6
  license = "MIT"
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import pickle
4
4
  import tempfile
5
+ from pathlib import Path
5
6
  from typing import TYPE_CHECKING, ClassVar
6
7
 
7
8
  import fake_useragent
@@ -22,8 +23,6 @@ except ImportError:
22
23
  _HAS_CACHE = False
23
24
 
24
25
  if TYPE_CHECKING:
25
- from pathlib import Path
26
-
27
26
  from requests import Response
28
27
 
29
28
 
@@ -80,7 +79,9 @@ class PersistentSession(Session):
80
79
 
81
80
  def save_cookies(self) -> None:
82
81
  """Save current cookies to file."""
83
- self._COOKIES_FILE.write_bytes(pickle.dumps(self.cookies, protocol=4))
82
+ temp_file = Path(tempfile.mktemp(dir=self._COOKIES_FILE.parent))
83
+ temp_file.write_bytes(pickle.dumps(self.cookies, protocol=4))
84
+ temp_file.replace(self._COOKIES_FILE)
84
85
 
85
86
  def request(self, *args: object, **kwargs: object) -> Response:
86
87
  """Override request method to save cookies after each request."""
File without changes
File without changes