Skip to content

Commit 83414b0

Browse files
new rclone: URLs, fixes #8446
rclone:remote:path
1 parent 4e576d5 commit 83414b0

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/borg/helpers/parseformat.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class Location:
469469

470470
rclone_re = re.compile(
471471
r"""
472-
(?P<proto>rclone):// # rclone://
472+
(?P<proto>rclone): # rclone:
473473
(?P<path>(.*))
474474
""",
475475
re.VERBOSE,
@@ -616,13 +616,16 @@ def canonical_path(self):
616616
path = "/./" + self.path # /./x = path x relative to cwd
617617
else:
618618
path = self.path
619-
return "{}://{}{}{}{}".format(
620-
self.proto if self.proto else "???",
621-
f"{self.user}@" if self.user else "",
622-
self._host if self._host else "", # needed for ipv6 addrs
623-
f":{self.port}" if self.port else "",
624-
path,
625-
)
619+
if self.proto == "rclone":
620+
return f"{self.proto}:{self.path}"
621+
else:
622+
return "{}://{}{}{}{}".format(
623+
self.proto if self.proto else "???",
624+
f"{self.user}@" if self.user else "",
625+
self._host if self._host else "", # needed for ipv6 addrs
626+
f":{self.port}" if self.port else "",
627+
path,
628+
)
626629

627630
def with_timestamp(self, timestamp):
628631
# note: this only affects the repository URL/path, not the archive name!

src/borg/testsuite/helpers_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ def test_ssh(self, monkeypatch, keys_dir):
190190
def test_rclone(self, monkeypatch, keys_dir):
191191
monkeypatch.delenv("BORG_REPO", raising=False)
192192
assert (
193-
repr(Location("rclone://remote:path"))
193+
repr(Location("rclone:remote:path"))
194194
== "Location(proto='rclone', user=None, host=None, port=None, path='remote:path')"
195195
)
196-
assert Location("rclone://remote:path").to_key_filename() == keys_dir + "remote_path"
196+
assert Location("rclone:remote:path").to_key_filename() == keys_dir + "remote_path"
197197

198198
def test_sftp(self, monkeypatch, keys_dir):
199199
monkeypatch.delenv("BORG_REPO", raising=False)

0 commit comments

Comments
 (0)