mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Revert "get: recoup cache optimal location"
This reverts commit 8e4922800f6ce47210976764af1c05e31e90deac.
This commit is contained in:
@@ -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
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user