Merge pull request #8719 from ThomasWaldmann/remove-make-parent-dirs-master

create: remove --make-parent-dirs option, #8619
This commit is contained in:
TW 2025-04-06 17:29:48 +02:00 committed by GitHub
commit 89daeabd7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 7 additions and 84 deletions

View file

@ -30,9 +30,7 @@ from ..logger import create_logger
logger = create_logger(__name__)
def get_repository(
location, *, create, exclusive, lock_wait, lock, append_only, make_parent_dirs, storage_quota, args, v1_or_v2
):
def get_repository(location, *, create, exclusive, lock_wait, lock, append_only, storage_quota, args, v1_or_v2):
if location.proto in ("ssh", "socket"):
RemoteRepoCls = LegacyRemoteRepository if v1_or_v2 else RemoteRepository
repository = RemoteRepoCls(
@ -42,7 +40,6 @@ def get_repository(
lock_wait=lock_wait,
lock=lock,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
args=args,
)
@ -54,7 +51,6 @@ def get_repository(
lock_wait=lock_wait,
lock=lock,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
storage_quota=storage_quota,
)
@ -67,7 +63,6 @@ def get_repository(
lock_wait=lock_wait,
lock=lock,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
storage_quota=storage_quota,
)
return repository
@ -133,7 +128,6 @@ def with_repository(
lock = getattr(args, "lock", _lock)
append_only = getattr(args, "append_only", False)
storage_quota = getattr(args, "storage_quota", None)
make_parent_dirs = getattr(args, "make_parent_dirs", False)
repository = get_repository(
location,
@ -142,7 +136,6 @@ def with_repository(
lock_wait=self.lock_wait,
lock=lock,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
storage_quota=storage_quota,
args=args,
v1_or_v2=False,
@ -212,7 +205,6 @@ def with_other_repository(manifest=False, cache=False, compatibility=None):
lock_wait=self.lock_wait,
lock=True,
append_only=False,
make_parent_dirs=False,
storage_quota=None,
args=args,
v1_or_v2=v1_or_v2,

View file

@ -245,12 +245,6 @@ class RepoCreateMixIn:
action=Highlander,
help="Set storage quota of the new repository (e.g. 5G, 1.5T). Default: no quota.",
)
subparser.add_argument(
"--make-parent-dirs",
dest="make_parent_dirs",
action="store_true",
help="create the parent directories of the repository directory, if they are missing.",
)
subparser.add_argument(
"--copy-crypt-key",
dest="copy_crypt_key",

View file

@ -246,15 +246,7 @@ class LegacyRemoteRepository:
return self.args[1]
def __init__(
self,
location,
create=False,
exclusive=False,
lock_wait=None,
lock=True,
append_only=False,
make_parent_dirs=False,
args=None,
self, location, create=False, exclusive=False, lock_wait=None, lock=True, append_only=False, args=None
):
self.location = self._location = location
self.preload_ids = []
@ -338,7 +330,6 @@ class LegacyRemoteRepository:
lock=lock,
exclusive=exclusive,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
v1_or_v2=True, # make remote use LegacyRepository
)
info = self.info()
@ -638,20 +629,9 @@ class LegacyRemoteRepository:
@api(
since=parse_version("1.0.0"),
append_only={"since": parse_version("1.0.7"), "previously": False},
make_parent_dirs={"since": parse_version("1.1.9"), "previously": False},
v1_or_v2={"since": parse_version("2.0.0b8"), "previously": True}, # TODO fix version
)
def open(
self,
path,
create=False,
lock_wait=None,
lock=True,
exclusive=False,
append_only=False,
make_parent_dirs=False,
v1_or_v2=False,
):
def open(self, path, create=False, lock_wait=None, lock=True, exclusive=False, append_only=False, v1_or_v2=False):
"""actual remoting is done via self.call in the @api decorator"""
@api(since=parse_version("2.0.0a3"))

View file

@ -202,7 +202,6 @@ class LegacyRepository:
lock=True,
append_only=False,
storage_quota=None,
make_parent_dirs=False,
send_log_cb=None,
):
self.path = os.path.abspath(path)
@ -234,7 +233,6 @@ class LegacyRepository:
self.storage_quota = storage_quota
self.storage_quota_use = 0
self.transaction_doomed = None
self.make_parent_dirs = make_parent_dirs
# v2 is the default repo version for borg 2.0
# v1 repos must only be used in a read-only way, e.g. for
# --other-repo=V1_REPO with borg init and borg transfer!
@ -336,14 +334,7 @@ class LegacyRepository:
def create(self, path):
"""Create a new empty repository at `path`"""
self.check_can_create_repository(path)
if self.make_parent_dirs:
parent_path = os.path.join(path, os.pardir)
os.makedirs(parent_path, exist_ok=True)
if not os.path.exists(path):
try:
os.mkdir(path)
except FileNotFoundError as err:
raise self.ParentPathDoesNotExist(path) from err
os.makedirs(path, exist_ok=True)
with open(os.path.join(path, "README"), "w") as fd:
fd.write(REPOSITORY_README)
os.mkdir(os.path.join(path, "data"))

View file

@ -365,17 +365,7 @@ class RepositoryServer: # pragma: no cover
path = os.path.realpath(path)
return path
def open(
self,
path,
create=False,
lock_wait=None,
lock=True,
exclusive=None,
append_only=False,
make_parent_dirs=False,
v1_or_v2=False,
):
def open(self, path, create=False, lock_wait=None, lock=True, exclusive=None, append_only=False, v1_or_v2=False):
self.RepoCls = LegacyRepository if v1_or_v2 else Repository
self.rpc_methods = self._legacy_rpc_methods if v1_or_v2 else self._rpc_methods
logging.debug("Resolving repository path %r", path)
@ -411,7 +401,6 @@ class RepositoryServer: # pragma: no cover
append_only=append_only,
storage_quota=self.storage_quota,
exclusive=exclusive,
make_parent_dirs=make_parent_dirs,
send_log_cb=self.send_queued_log,
)
self.repository.__enter__() # clean exit handled by serve() method
@ -580,17 +569,7 @@ class RemoteRepository:
def required_version(self):
return self.args[1]
def __init__(
self,
location,
create=False,
exclusive=False,
lock_wait=1.0,
lock=True,
append_only=False,
make_parent_dirs=False,
args=None,
):
def __init__(self, location, create=False, exclusive=False, lock_wait=1.0, lock=True, append_only=False, args=None):
self.location = self._location = location
self.preload_ids = []
self.msgid = 0
@ -673,7 +652,6 @@ class RemoteRepository:
lock=lock,
exclusive=exclusive,
append_only=append_only,
make_parent_dirs=make_parent_dirs,
)
info = self.info()
self.version = info["version"]
@ -976,20 +954,9 @@ class RemoteRepository:
@api(
since=parse_version("1.0.0"),
append_only={"since": parse_version("1.0.7"), "previously": False},
make_parent_dirs={"since": parse_version("1.1.9"), "previously": False},
v1_or_v2={"since": parse_version("2.0.0b8"), "previously": True}, # TODO fix version
)
def open(
self,
path,
create=False,
lock_wait=None,
lock=True,
exclusive=False,
append_only=False,
make_parent_dirs=False,
v1_or_v2=False,
):
def open(self, path, create=False, lock_wait=None, lock=True, exclusive=False, append_only=False, v1_or_v2=False):
"""actual remoting is done via self.call in the @api decorator"""
@api(since=parse_version("2.0.0a3"))

View file

@ -105,7 +105,6 @@ class Repository:
lock=True,
append_only=False,
storage_quota=None,
make_parent_dirs=False,
send_log_cb=None,
):
if isinstance(path_or_location, Location):