diff --git a/dvc/external_repo.py b/dvc/external_repo.py index 8f7cfaef55..9ff2f2a413 100644 --- a/dvc/external_repo.py +++ b/dvc/external_repo.py @@ -33,7 +33,7 @@ def external_repo(url=None, rev=None, rev_lock=None, cache_dir=None): repo.close() -def cached_clone(url, rev=None, clone_path=None, **_ignored_kwargs): +def cached_clone(url, rev=None, **_ignored_kwargs): """Clone an external git repo to a temporary directory. Returns the path to a local temporary directory with the specified @@ -44,7 +44,7 @@ def cached_clone(url, rev=None, clone_path=None, **_ignored_kwargs): """ - new_path = clone_path or tempfile.mkdtemp("dvc-erepo") + new_path = tempfile.mkdtemp("dvc-erepo") # Copy and adjust existing clean clone if (url, None, None) in REPO_CACHE: diff --git a/dvc/repo/get.py b/dvc/repo/get.py index 785c388a4a..49bb4e9013 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -3,6 +3,8 @@ import shortuuid +from dvc.cache import CacheConfig +from dvc.config import Config from dvc.exceptions import ( DvcException, NotDvcRepoError, @@ -49,9 +51,11 @@ def get(url, path, out=None, rev=None): dpath = os.path.dirname(os.path.abspath(out)) tmp_dir = os.path.join(dpath, "." + str(shortuuid.uuid())) try: - cached_clone(url, rev=rev, clone_path=tmp_dir) + clone_dir = cached_clone(url, rev=rev) try: - repo = Repo(tmp_dir) + repo = Repo(clone_dir) + cache_config = CacheConfig(repo.config) + cache_config.set_dir(tmp_dir, level=Config.LEVEL_LOCAL) # Try any links possible to avoid data duplication. # @@ -78,12 +82,13 @@ def get(url, path, out=None, rev=None): if os.path.isabs(path): raise FileNotFoundError - fs_copy(os.path.join(tmp_dir, path), out) + fs_copy(os.path.join(clone_dir, path), out) except (OutputNotFoundError, FileNotFoundError): raise PathMissingError(path, url) finally: remove(tmp_dir) + remove(clone_dir) def _get_cached(repo, output, out):