From ca5fc5769ab785b84f64db845e7ec2ad3405af1d Mon Sep 17 00:00:00 2001 From: Andrey Bienkowski Date: Tue, 30 Nov 2021 20:38:38 +0300 Subject: [PATCH 1/3] Test that archive name is not mentioned; see #6014 --- src/borg/testsuite/archiver.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 2305cdaab..384751179 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -3529,6 +3529,14 @@ class RemoteArchiverTestCase(ArchiverTestCase): res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '0') self.assert_true(marker not in res) + @pytest.mark.xfail(raises=AssertionError, strict=True) + def test_do_not_mention_archive_if_you_can_not_find_repo(self): + """https://github.com/borgbackup/borg/issues/6014""" + archive = self.repository_location + '-this-repository-does-not-exist' + '::test' + output = self.cmd(*['info', archive], exit_code=2, fork=True) + self.assert_in('this-repository-does-not-exist', output) + self.assert_not_in('this-repository-does-not-exist::test', output) + class ArchiverCorruptionTestCase(ArchiverTestCaseBase): def setUp(self): From 36998f3178575fbdd50ecf1198172cf20e8c3f96 Mon Sep 17 00:00:00 2001 From: Andrey Bienkowski Date: Tue, 30 Nov 2021 16:48:19 +0300 Subject: [PATCH 2/3] Backport #6023 (do not show archive name in error msgs referring to repository) --- src/borg/archiver.py | 2 +- src/borg/helpers.py | 6 ++++++ src/borg/testsuite/archiver.py | 1 - src/borg/testsuite/helpers.py | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index f45ff3058..7d18f0110 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -152,7 +152,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.py b/src/borg/helpers.py index ccd7f917e..5af7650cd 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1232,6 +1232,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/archiver.py b/src/borg/testsuite/archiver.py index 384751179..d6303378f 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -3529,7 +3529,6 @@ class RemoteArchiverTestCase(ArchiverTestCase): res = self.cmd('extract', "--debug", self.repository_location + '::test', '--strip-components', '0') self.assert_true(marker not in res) - @pytest.mark.xfail(raises=AssertionError, strict=True) def test_do_not_mention_archive_if_you_can_not_find_repo(self): """https://github.com/borgbackup/borg/issues/6014""" archive = self.repository_location + '-this-repository-does-not-exist' + '::test' diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py index 43ccb1d9b..04331c55f 100644 --- a/src/borg/testsuite/helpers.py +++ b/src/borg/testsuite/helpers.py @@ -231,6 +231,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): From 6713a2584684fd212afe96066dae9c15281b51c2 Mon Sep 17 00:00:00 2001 From: Andrey Bienkowski Date: Thu, 2 Dec 2021 07:31:33 +0300 Subject: [PATCH 3/3] [fixup] don't use star args Per your contribution guidelines I made a separate fixup commit --- src/borg/testsuite/archiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index d6303378f..16d2c275f 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -3532,7 +3532,7 @@ class RemoteArchiverTestCase(ArchiverTestCase): def test_do_not_mention_archive_if_you_can_not_find_repo(self): """https://github.com/borgbackup/borg/issues/6014""" archive = self.repository_location + '-this-repository-does-not-exist' + '::test' - output = self.cmd(*['info', archive], exit_code=2, fork=True) + output = self.cmd('info', archive, exit_code=2, fork=True) self.assert_in('this-repository-does-not-exist', output) self.assert_not_in('this-repository-does-not-exist::test', output)