diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 45c8bf1c9..dee85d6db 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -379,23 +379,16 @@ class Repo: @property def data_index(self) -> Optional["DataIndex"]: - from appdirs import user_cache_dir - from fsspec.utils import tokenize - from dvc_data.index import DataIndex if not self.config["feature"].get("data_index_cache"): return None + if not self.index_db_dir: + return None + if self._data_index is None: - cache_dir = user_cache_dir(self.config.APPNAME, self.config.APPAUTHOR) - index_dir = os.path.join( - cache_dir, - "index", - "data", - # scm.root_dir and repo.root_dir don't match for subrepos - tokenize((self.scm.root_dir, self.root_dir)), - ) + index_dir = os.path.join(self.index_db_dir, "data") os.makedirs(index_dir, exist_ok=True) self._data_index = DataIndex.open(os.path.join(index_dir, "db.db"))