diff --git a/src/borg/archiver/rinfo_cmd.py b/src/borg/archiver/rinfo_cmd.py index 221d05fc0..bba038117 100644 --- a/src/borg/archiver/rinfo_cmd.py +++ b/src/borg/archiver/rinfo_cmd.py @@ -59,16 +59,9 @@ class RInfoMixIn: output += f" out of {format_file_size(storage_quota, iec=args.iec)}" output += "\n" - output += ( - textwrap.dedent( - """ - Cache: {cache.path} - Security dir: {security_dir} - """ - ) - .strip() - .format(**info) - ) + if hasattr(info["cache"], "path"): + output += "Cache: {cache.path}\n".format(**info) + output += "Security dir: {security_dir}\n".format(**info) print(output) print(str(cache)) diff --git a/src/borg/testsuite/archiver/corruption.py b/src/borg/testsuite/archiver/corruption.py index cb8b55417..0df305e00 100644 --- a/src/borg/testsuite/archiver/corruption.py +++ b/src/borg/testsuite/archiver/corruption.py @@ -34,7 +34,7 @@ def test_check_corrupted_repository(archiver): def corrupt_archiver(archiver): create_test_files(archiver.input_path) cmd(archiver, "rcreate", RK_ENCRYPTION) - archiver.cache_path = json.loads(cmd(archiver, "rinfo", "--json"))["cache"]["path"] + archiver.cache_path = json.loads(cmd(archiver, "rinfo", "--json"))["cache"].get("path") def corrupt(file, amount=1): @@ -48,6 +48,9 @@ def corrupt(file, amount=1): @pytest.mark.allow_cache_wipe def test_cache_chunks(archiver): corrupt_archiver(archiver) + if archiver.cache_path is None: + pytest.skip("no cache path for this kind of Cache implementation") + create_src_archive(archiver, "test") chunks_path = os.path.join(archiver.cache_path, "chunks") chunks_before_corruption = set(ChunkIndex(path=chunks_path).iteritems()) @@ -74,6 +77,9 @@ def test_cache_chunks(archiver): def test_cache_files(archiver): corrupt_archiver(archiver) + if archiver.cache_path is None: + pytest.skip("no cache path for this kind of Cache implementation") + cmd(archiver, "create", "test", "input") corrupt(os.path.join(archiver.cache_path, "files")) out = cmd(archiver, "create", "test1", "input") @@ -83,6 +89,9 @@ def test_cache_files(archiver): def test_chunks_archive(archiver): corrupt_archiver(archiver) + if archiver.cache_path is None: + pytest.skip("no cache path for this kind of Cache implementation") + cmd(archiver, "create", "test1", "input") # Find ID of test1, so we can corrupt it later :) target_id = cmd(archiver, "rlist", "--format={id}{NL}").strip() @@ -114,6 +123,9 @@ def test_chunks_archive(archiver): def test_old_version_interfered(archiver): corrupt_archiver(archiver) + if archiver.cache_path is None: + pytest.skip("no cache path for this kind of Cache implementation") + # Modify the main manifest ID without touching the manifest ID in the integrity section. # This happens if a version without integrity checking modifies the cache. config_path = os.path.join(archiver.cache_path, "config")