From 72f2ee31efec9df593e0cc8e772b0c97122813b8 Mon Sep 17 00:00:00 2001 From: karanjakhar Date: Mon, 13 Feb 2023 10:02:20 +0530 Subject: [PATCH] fixes #8705 issue --- dvc/cachemgr.py | 9 ++++++++- dvc/repo/__init__.py | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dvc/cachemgr.py b/dvc/cachemgr.py index 65984084381..8789d995e3e 100644 --- a/dvc/cachemgr.py +++ b/dvc/cachemgr.py @@ -1,4 +1,4 @@ -from dvc.fs import GitFileSystem, Schemes +from dvc.fs import GitFileSystem, LocalFileSystem, Schemes from dvc_data.hashfile.db import get_odb @@ -11,6 +11,13 @@ def _get_odb(repo, settings, fs=None): cls, config, fs_path = get_cloud_fs(repo, **settings) config["tmp_dir"] = repo.tmp_dir fs = fs or cls(**config) + + if ( + isinstance(repo.fs, GitFileSystem) + and isinstance(fs, LocalFileSystem) + and fs_path[:-10] == "/" + ): + fs_path = fs.path.join(repo.abs_root_dir, fs_path[1:]) return get_odb(fs, fs_path, state=repo.state, **config) diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index ecfc39221f9..4e2017666cb 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -180,6 +180,13 @@ def __init__( self._fs = fs or localfs self._scm = scm + self.abs_root_dir, _, _ = self._get_repo_dirs( + root_dir=root_dir, + fs=self.fs, + uninitialized=uninitialized, + scm=scm, + ) + if rev and not fs: self._scm = scm = SCM(root_dir or os.curdir) root_dir = "/"