1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-27 18:28:42 +00:00

Repository.open: use stat() to check for repo dir, fixes #4695

(cherry picked from commit ec3fad0f85)
This commit is contained in:
Thomas Waldmann 2019-07-29 14:54:20 +02:00 committed by Saurav Sachidanand
parent e299ad824c
commit bb7a9e6c20

View file

@ -2,6 +2,7 @@
import mmap
import os
import shutil
import stat
import struct
import time
from binascii import hexlify, unhexlify
@ -386,8 +387,12 @@ def migrate_lock(self, old_id, new_id):
def open(self, path, exclusive, lock_wait=None, lock=True):
self.path = path
if not os.path.isdir(path):
try:
st = os.stat(path)
except FileNotFoundError:
raise self.DoesNotExist(path)
if not stat.S_ISDIR(st.st_mode):
raise self.InvalidRepository(path)
if lock:
self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait).acquire()
else: