mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-28 10:49:16 +00:00
Repository.check_can_create_repository: use stat() to check
similar issue as #4695.
(cherry picked from commit 4911720faf
)
This commit is contained in:
parent
bb7a9e6c20
commit
8b49c4d2df
1 changed files with 8 additions and 2 deletions
|
@ -234,11 +234,17 @@ def check_can_create_repository(self, path):
|
|||
repository, user's can only use the quota'd repository, when their --restrict-to-path points
|
||||
at the user's repository.
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except FileNotFoundError:
|
||||
pass # nothing there!
|
||||
else:
|
||||
# there is something already there!
|
||||
if self.is_repository(path):
|
||||
raise self.AlreadyExists(path)
|
||||
if not os.path.isdir(path) or os.listdir(path):
|
||||
if not stat.S_ISDIR(st.st_mode) or os.listdir(path):
|
||||
raise self.PathAlreadyExists(path)
|
||||
# an empty directory is acceptable for us.
|
||||
|
||||
while True:
|
||||
# Check all parent directories for Borg's repository README
|
||||
|
|
Loading…
Reference in a new issue