AdHocCache has no cache persistence

thus:

- no cache.path
- skip on-disk cache corruption tests for AdHocCache
This commit is contained in:
Thomas Waldmann 2023-09-28 00:16:15 +02:00
parent 186d536d55
commit 5ec557908c
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
2 changed files with 16 additions and 11 deletions

View File

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

View File

@ -32,7 +32,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):
@ -45,6 +45,9 @@ def corrupt(file, amount=1):
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")
corrupt(os.path.join(archiver.cache_path, "chunks"))
if archiver.FORK_DEFAULT:
out = cmd(archiver, "rinfo", exit_code=2)
@ -56,6 +59,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")
@ -65,6 +71,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()
@ -96,6 +105,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")