Merging upstream version 2.7.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
5aec43d541
commit
57d38a2ac5
24 changed files with 323 additions and 99 deletions
pre_commit
|
@ -43,6 +43,10 @@ class Store:
|
|||
def __init__(self, directory: Optional[str] = None) -> None:
|
||||
self.directory = directory or Store.get_default_directory()
|
||||
self.db_path = os.path.join(self.directory, 'db.db')
|
||||
self.readonly = (
|
||||
os.path.exists(self.directory) and
|
||||
not os.access(self.directory, os.W_OK)
|
||||
)
|
||||
|
||||
if not os.path.exists(self.directory):
|
||||
os.makedirs(self.directory, exist_ok=True)
|
||||
|
@ -75,7 +79,7 @@ class Store:
|
|||
self._create_config_table(db)
|
||||
|
||||
# Atomic file move
|
||||
os.rename(tmpfile, self.db_path)
|
||||
os.replace(tmpfile, self.db_path)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def exclusive_lock(self) -> Generator[None, None, None]:
|
||||
|
@ -218,6 +222,8 @@ class Store:
|
|||
)
|
||||
|
||||
def mark_config_used(self, path: str) -> None:
|
||||
if self.readonly: # pragma: win32 no cover
|
||||
return
|
||||
path = os.path.realpath(path)
|
||||
# don't insert config files that do not exist
|
||||
if not os.path.exists(path):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue