From fec3568cba6c82c37b7aea03f40fe206ee207142 Mon Sep 17 00:00:00 2001 From: sw9719 <92990844+sw9719@users.noreply.github.com> Date: Thu, 11 Nov 2021 04:57:39 +0530 Subject: [PATCH] do not show archive name in error msgs referring to repository (#6023) do not show archive name in repo error msgs, fix #6014 --- src/borg/archiver.py | 2 +- src/borg/helpers/parseformat.py | 6 ++++++ src/borg/testsuite/helpers.py | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 60081f761..daae7e782 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -158,7 +158,7 @@ def with_repository(fake=False, invert_fake=False, create=False, lock=True, if argument(args, fake) ^ invert_fake: return method(self, args, repository=None, **kwargs) elif location.proto == 'ssh': - repository = RemoteRepository(location, create=create, exclusive=argument(args, exclusive), + repository = RemoteRepository(location.omit_archive(), create=create, exclusive=argument(args, exclusive), lock_wait=self.lock_wait, lock=lock, append_only=append_only, make_parent_dirs=make_parent_dirs, args=args) else: diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 96d1b31a5..247ea9be7 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -492,6 +492,12 @@ class Location: 'utcnow': DatetimeWrapper(timestamp), }) + def omit_archive(self): + loc = Location(self.orig) + loc.archive = None + loc.orig = loc.orig.split("::")[0] + return loc + def location_validator(archive=None, proto=None): def validator(text): diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py index df4e0caa2..642ea725a 100644 --- a/src/borg/testsuite/helpers.py +++ b/src/borg/testsuite/helpers.py @@ -234,6 +234,12 @@ class TestLocationWithoutEnv: # this is invalid due to the 2nd colon, correct: 'ssh://user@host/path' Location('ssh://user@host:/path') + def test_omit_archive(self): + loc = Location('ssh://user@host:1234/some/path::archive') + loc_without_archive = loc.omit_archive() + assert loc_without_archive.archive is None + assert loc_without_archive.orig == "ssh://user@host:1234/some/path" + class TestLocationWithEnv: def test_ssh(self, monkeypatch):