increase compatibility with windows 11.
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import dataclasses
|
||||
import fcntl
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@ -11,6 +10,7 @@ from pydantic.tools import parse_obj_as
|
||||
from mdrsclient.exceptions import UnexpectedException
|
||||
from mdrsclient.models import Laboratories, Token, User
|
||||
from mdrsclient.settings import CONFIG_DIRNAME
|
||||
from mdrsclient.utils import FileLock
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -125,9 +125,10 @@ class CacheFile:
|
||||
def __save(self) -> None:
|
||||
self.__ensure_cache_dir()
|
||||
with open(self.__cache_file, "w") as f:
|
||||
fcntl.flock(f, fcntl.LOCK_EX)
|
||||
FileLock.lock(f)
|
||||
self.__data.update_digest()
|
||||
f.write(json.dumps(dataclasses.asdict(self.__data)))
|
||||
FileLock.unlock(f)
|
||||
stat = os.stat(self.__cache_file)
|
||||
self.__serial = hash((stat.st_uid, stat.st_gid, stat.st_mode, stat.st_size, stat.st_mtime))
|
||||
# ensure file is secure.
|
||||
|
Reference in New Issue
Block a user