Browse Source

new rclone: URLs, fixes #8446

rclone:remote:path
Thomas Waldmann 8 months ago
parent
commit
83414b037d
2 changed files with 13 additions and 10 deletions
  1. 11 8
      src/borg/helpers/parseformat.py
  2. 2 2
      src/borg/testsuite/helpers_test.py

+ 11 - 8
src/borg/helpers/parseformat.py

@@ -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!

+ 2 - 2
src/borg/testsuite/helpers_test.py

@@ -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)