1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-08 21:05:23 +00:00

new rclone: URLs, fixes #8446

rclone:remote:path
This commit is contained in:
Thomas Waldmann 2024-10-13 21:40:31 +02:00
parent 4e576d51c7
commit 83414b037d
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 13 additions and 10 deletions

View file

@ -469,7 +469,7 @@ class Location:
rclone_re = re.compile(
r"""
(?P<proto>rclone):// # rclone://
(?P<proto>rclone): # rclone:
(?P<path>(.*))
""",
re.VERBOSE,
@ -616,13 +616,16 @@ class Location:
path = "/./" + self.path # /./x = path x relative to cwd
else:
path = self.path
return "{}://{}{}{}{}".format(
self.proto if self.proto else "???",
f"{self.user}@" if self.user else "",
self._host if self._host else "", # needed for ipv6 addrs
f":{self.port}" if self.port else "",
path,
)
if self.proto == "rclone":
return f"{self.proto}:{self.path}"
else:
return "{}://{}{}{}{}".format(
self.proto if self.proto else "???",
f"{self.user}@" if self.user else "",
self._host if self._host else "", # needed for ipv6 addrs
f":{self.port}" if self.port else "",
path,
)
def with_timestamp(self, timestamp):
# note: this only affects the repository URL/path, not the archive name!

View file

@ -190,10 +190,10 @@ class TestLocationWithoutEnv:
def test_rclone(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
assert (
repr(Location("rclone://remote:path"))
repr(Location("rclone:remote:path"))
== "Location(proto='rclone', user=None, host=None, port=None, path='remote:path')"
)
assert Location("rclone://remote:path").to_key_filename() == keys_dir + "remote_path"
assert Location("rclone:remote:path").to_key_filename() == keys_dir + "remote_path"
def test_sftp(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)