diff --git a/dvc/cachemgr.py b/dvc/cachemgr.py index 1473c5961..2300323da 100644 --- a/dvc/cachemgr.py +++ b/dvc/cachemgr.py @@ -36,6 +36,7 @@ def _get_odb( class CacheManager: CACHE_DIR = "cache" FILES_DIR = "files" + FS_DIR = "fs" def __init__(self, repo): self._repo = repo @@ -73,6 +74,21 @@ class CacheManager: legacy_odb = _get_odb(repo, settings, hash_name="md5-dos2unix", **kwargs) self._odb["legacy"] = legacy_odb + @property + def fs_cache(self): + """Filesystem-based cache. + + Currently used as a temporary location to download files that we don't + yet have a regular oid (e.g. md5) for. + """ + from dvc_data.index import FileStorage + + return FileStorage( + key=(), + fs=self.local.fs, + path=self.local.fs.path.join(self.default_local_cache_dir, self.FS_DIR), + ) + def _init_odb(self, schemes): for scheme in schemes: remote = self.config.get(scheme) diff --git a/dvc/repo/index.py b/dvc/repo/index.py index e9d39ac87..5eb0a2c6a 100644 --- a/dvc/repo/index.py +++ b/dvc/repo/index.py @@ -186,12 +186,13 @@ def _load_storage_from_out(storage_map, key, out): from fsspec.utils import tokenize # partial import + fs_cache = out.repo.cache.fs_cache storage_map.add_cache( FileStorage( key, - out.cache.fs, - out.cache.fs.path.join( - out.cache.path, "fs", dep.fs.protocol, tokenize(dep.fs_path) + fs_cache.fs, + fs_cache.fs.path.join( + fs_cache.path, dep.fs.protocol, tokenize(dep.fs_path) ), ) )