Revert "get: recoup cache optimal location"

This reverts commit 8e4922800f6ce47210976764af1c05e31e90deac.
This commit is contained in:
Fábio Santos
2020-01-10 22:28:24 +00:00
parent a01f81ed09
commit 6cb7308cdb
2 changed files with 5 additions and 10 deletions
+2 -2
View File
@@ -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, **_ignored_kwargs):
def cached_clone(url, rev=None, clone_path=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, **_ignored_kwargs):
"""
new_path = tempfile.mkdtemp("dvc-erepo")
new_path = clone_path or tempfile.mkdtemp("dvc-erepo")
# Copy and adjust existing clean clone
if (url, None, None) in REPO_CACHE:
+3 -8
View File
@@ -3,8 +3,6 @@ import os
import shortuuid
from dvc.cache import CacheConfig
from dvc.config import Config
from dvc.exceptions import (
DvcException,
NotDvcRepoError,
@@ -51,11 +49,9 @@ 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:
clone_dir = cached_clone(url, rev=rev)
cached_clone(url, rev=rev, clone_path=tmp_dir)
try:
repo = Repo(clone_dir)
cache_config = CacheConfig(repo.config)
cache_config.set_dir(tmp_dir, level=Config.LEVEL_LOCAL)
repo = Repo(tmp_dir)
# Try any links possible to avoid data duplication.
#
@@ -81,13 +77,12 @@ def get(url, path, out=None, rev=None):
if os.path.isabs(path):
raise FileNotFoundError
fs_copy(os.path.join(clone_dir, path), out)
fs_copy(os.path.join(tmp_dir, path), out)
except (OutputNotFoundError, FileNotFoundError):
raise PathMissingError(path, url)
finally:
remove(tmp_dir)
remove(clone_dir)
def _get_cached(repo, output, out):