mirror of https://github.com/borgbackup/borg.git
rename NewCache -> AdHocWithFilesCache
This commit is contained in:
parent
78954b6487
commit
5a500cddf8
|
@ -93,7 +93,7 @@ General:
|
|||
- ``adhoc``: builds a non-persistent chunks cache by querying the repo. Chunks cache contents
|
||||
are somewhat sloppy for already existing chunks, concerning their refcount ("infinite") and
|
||||
size (0). No files cache (slow, will chunk all input files). DEPRECATED.
|
||||
- ``newcache``: Like ``adhoc``, but with a persistent files cache.
|
||||
- ``adhocwithfiles``: Like ``adhoc``, but with a persistent files cache.
|
||||
BORG_SELFTEST
|
||||
This can be used to influence borg's builtin self-tests. The default is to execute the tests
|
||||
at the beginning of each borg command invocation.
|
||||
|
|
|
@ -2334,7 +2334,7 @@ class ArchiveChecker:
|
|||
logger.info(f"{len(orphaned)} orphaned (unused) objects found.")
|
||||
for chunk_id in orphaned:
|
||||
logger.debug(f"chunk {bin_to_hex(chunk_id)} is orphaned.")
|
||||
# To support working with AdHocCache or NewCache, we do not set self.error_found = True.
|
||||
# To support working with AdHocCache or AdHocWithFilesCache, we do not set self.error_found = True.
|
||||
if self.repair and unused:
|
||||
logger.info(
|
||||
"Deleting %d orphaned and %d superseded objects..." % (len(orphaned), len(self.possibly_superseded))
|
||||
|
|
|
@ -815,7 +815,7 @@ class CreateMixIn:
|
|||
"--prefer-adhoc-cache",
|
||||
dest="prefer_adhoc_cache",
|
||||
action="store_true",
|
||||
help="experimental: prefer AdHocCache (w/o files cache) over NewCache (with files cache).",
|
||||
help="experimental: prefer AdHocCache (w/o files cache) over AdHocWithFilesCache (with files cache).",
|
||||
)
|
||||
subparser.add_argument(
|
||||
"--stdin-name",
|
||||
|
|
|
@ -368,8 +368,8 @@ class Cache:
|
|||
cache_mode=cache_mode,
|
||||
)
|
||||
|
||||
def newcache():
|
||||
return NewCache(
|
||||
def adhocwithfiles():
|
||||
return AdHocWithFilesCache(
|
||||
manifest=manifest,
|
||||
path=path,
|
||||
warn_if_unencrypted=warn_if_unencrypted,
|
||||
|
@ -384,7 +384,7 @@ class Cache:
|
|||
|
||||
impl = os.environ.get("BORG_CACHE_IMPL", None)
|
||||
if impl is not None:
|
||||
methods = dict(local=local, newcache=newcache, adhoc=adhoc)
|
||||
methods = dict(local=local, adhocwithfiles=adhocwithfiles, adhoc=adhoc)
|
||||
try:
|
||||
method = methods[impl]
|
||||
except KeyError:
|
||||
|
@ -392,13 +392,13 @@ class Cache:
|
|||
return method()
|
||||
|
||||
if no_cache_sync_forced:
|
||||
return adhoc() if prefer_adhoc_cache else newcache()
|
||||
return adhoc() if prefer_adhoc_cache else adhocwithfiles()
|
||||
|
||||
if not no_cache_sync_permitted:
|
||||
return local()
|
||||
|
||||
# no cache sync may be permitted, but if the local cache is in sync it'd be stupid to invalidate
|
||||
# it by needlessly using the AdHocCache or the NewCache.
|
||||
# it by needlessly using the AdHocCache or the AdHocWithFilesCache.
|
||||
# Check if the local cache exists and is in sync.
|
||||
|
||||
cache_config = CacheConfig(repository, path, lock_wait)
|
||||
|
@ -410,12 +410,12 @@ class Cache:
|
|||
# Local cache is in sync, use it
|
||||
logger.debug("Cache: choosing local cache (in sync)")
|
||||
return local()
|
||||
if prefer_adhoc_cache:
|
||||
if prefer_adhoc_cache: # adhoc cache, without files cache
|
||||
logger.debug("Cache: choosing AdHocCache (local cache does not exist or is not in sync)")
|
||||
return adhoc()
|
||||
else:
|
||||
logger.debug("Cache: choosing NewCache (local cache does not exist or is not in sync)")
|
||||
return newcache()
|
||||
logger.debug("Cache: choosing AdHocWithFilesCache (local cache does not exist or is not in sync)")
|
||||
return adhocwithfiles()
|
||||
|
||||
|
||||
class CacheStatsMixin:
|
||||
|
@ -675,7 +675,7 @@ class ChunksMixin:
|
|||
"chunk has same id [%r], but different size (stored: %d new: %d)!" % (id, entry.size, size)
|
||||
)
|
||||
else:
|
||||
# NewCache / AdHocCache:
|
||||
# AdHocWithFilesCache / AdHocCache:
|
||||
# Here *size* is used to update the chunk's size information, which will be zero for existing chunks.
|
||||
self.chunks[id] = entry._replace(size=size)
|
||||
return entry.refcount
|
||||
|
@ -1162,7 +1162,7 @@ class LocalCache(CacheStatsMixin, FilesCacheMixin, ChunksMixin):
|
|||
self.cache_config.mandatory_features.update(repo_features & my_features)
|
||||
|
||||
|
||||
class NewCache(CacheStatsMixin, FilesCacheMixin, ChunksMixin):
|
||||
class AdHocWithFilesCache(CacheStatsMixin, FilesCacheMixin, ChunksMixin):
|
||||
"""
|
||||
Like AdHocCache, but with a files cache.
|
||||
"""
|
||||
|
|
|
@ -1184,13 +1184,13 @@ class BorgJsonEncoder(json.JSONEncoder):
|
|||
from ..repository import Repository
|
||||
from ..remote import RemoteRepository
|
||||
from ..archive import Archive
|
||||
from ..cache import LocalCache, AdHocCache, NewCache
|
||||
from ..cache import LocalCache, AdHocCache, AdHocWithFilesCache
|
||||
|
||||
if isinstance(o, Repository) or isinstance(o, RemoteRepository):
|
||||
return {"id": bin_to_hex(o.id), "location": o._location.canonical_path()}
|
||||
if isinstance(o, Archive):
|
||||
return o.info()
|
||||
if isinstance(o, (LocalCache, NewCache)):
|
||||
if isinstance(o, (LocalCache, AdHocWithFilesCache)):
|
||||
return {"path": o.path, "stats": o.stats()}
|
||||
if isinstance(o, AdHocCache):
|
||||
return {"stats": o.stats()}
|
||||
|
|
|
@ -357,7 +357,7 @@ def check_cache(archiver):
|
|||
with Cache(repository, manifest, sync=False) as cache:
|
||||
original_chunks = cache.chunks
|
||||
# the LocalCache implementation has an on-disk chunks cache,
|
||||
# but NewCache and AdHocCache don't have persistent chunks cache.
|
||||
# but AdHocWithFilesCache and AdHocCache don't have persistent chunks cache.
|
||||
persistent = isinstance(cache, LocalCache)
|
||||
Cache.destroy(repository)
|
||||
with Cache(repository, manifest) as cache:
|
||||
|
|
|
@ -204,7 +204,9 @@ def test_unknown_feature_on_create(archivers, request):
|
|||
cmd_raises_unknown_feature(archiver, ["create", "test", "input"])
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.environ.get("BORG_CACHE_IMPL") in ("newcache", "adhoc"), reason="only works with LocalCache")
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("BORG_CACHE_IMPL") in ("adhocwithfiles", "adhoc"), reason="only works with LocalCache"
|
||||
)
|
||||
def test_unknown_feature_on_cache_sync(archivers, request):
|
||||
# LocalCache.sync checks repo compat
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
@ -324,7 +326,9 @@ def test_check_cache(archivers, request):
|
|||
check_cache(archiver)
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.environ.get("BORG_CACHE_IMPL") in ("newcache", "adhoc"), reason="only works with LocalCache")
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("BORG_CACHE_IMPL") in ("adhocwithfiles", "adhoc"), reason="only works with LocalCache"
|
||||
)
|
||||
def test_env_use_chunks_archive(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
|
|
|
@ -540,8 +540,10 @@ def test_create_pattern_intermediate_folders_first(archivers, request):
|
|||
assert out_list.index("d x/b") < out_list.index("- x/b/foo_b")
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.environ.get("BORG_CACHE_IMPL") in ("newcache", "local"), reason="only works with AdHocCache")
|
||||
def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for NewCache
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("BORG_CACHE_IMPL") in ("adhocwithfiles", "local"), reason="only works with AdHocCache"
|
||||
)
|
||||
def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for AdHocWithFilesCache
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
|
|
|
@ -169,7 +169,7 @@ def test_debug_refcount_obj(archivers, request):
|
|||
archive_id = create_json["archive"]["id"]
|
||||
output = cmd(archiver, "debug", "refcount-obj", archive_id).strip()
|
||||
# LocalCache does precise refcounting, so we'll get 1 reference for the archive.
|
||||
# AdHocCache or NewCache doesn't, we'll get ChunkIndex.MAX_VALUE as refcount.
|
||||
# AdHocCache or AdHocWithFilesCache doesn't, we'll get ChunkIndex.MAX_VALUE as refcount.
|
||||
assert (
|
||||
output == f"object {archive_id} has 1 referrers [info from chunks cache]."
|
||||
or output == f"object {archive_id} has 4294966271 referrers [info from chunks cache]."
|
||||
|
|
|
@ -127,7 +127,7 @@ def archiver(tmp_path, set_env_variables):
|
|||
archiver.patterns_file_path = os.fspath(tmp_path / "patterns")
|
||||
os.environ["BORG_KEYS_DIR"] = archiver.keys_path
|
||||
os.environ["BORG_CACHE_DIR"] = archiver.cache_path
|
||||
# os.environ["BORG_CACHE_IMPL"] = "newcache"
|
||||
# os.environ["BORG_CACHE_IMPL"] = "adhocwithfiles"
|
||||
os.mkdir(archiver.input_path)
|
||||
os.chmod(archiver.input_path, 0o777) # avoid troubles with fakeroot / FUSE
|
||||
os.mkdir(archiver.output_path)
|
||||
|
|
Loading…
Reference in New Issue