diff --git a/dvc/repo/get.py b/dvc/repo/get.py index 3eb209d73..011700684 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -3,7 +3,6 @@ import os import shortuuid -from dvc.config import Config from dvc.exceptions import GetDVCFileError from dvc.exceptions import NotDvcRepoError from dvc.exceptions import OutputNotFoundError @@ -48,11 +47,7 @@ def get(url, path, out=None, rev=None): # # Also, we can't use theoretical "move" link type here, because # the same cache file might be used a few times in a directory. - repo.config.set( - Config.SECTION_CACHE, - Config.SECTION_CACHE_TYPE, - "reflink,hardlink,copy", - ) + repo.cache.local.cache_types = ["reflink", "hardlink", "copy"] o = repo.find_out_by_relpath(path) with repo.state: diff --git a/tests/func/test_get.py b/tests/func/test_get.py index 2dcba2ba8..18afef5b5 100644 --- a/tests/func/test_get.py +++ b/tests/func/test_get.py @@ -5,9 +5,11 @@ import os import pytest +from dvc.config import Config from dvc.exceptions import GetDVCFileError from dvc.exceptions import UrlNotDvcRepoError from dvc.repo import Repo +from dvc.system import System from dvc.utils import makedirs from tests.utils import trees_equal @@ -34,6 +36,23 @@ def test_get_repo_dir(repo_dir, erepo): trees_equal(src, dst) +def test_cache_type_is_properly_overridden(repo_dir, erepo): + erepo.dvc.config.set( + Config.SECTION_CACHE, Config.SECTION_CACHE_TYPE, "symlink" + ) + erepo.dvc.scm.add([erepo.dvc.config.config_file]) + erepo.dvc.scm.commit("set cache type to symlinks") + + src = erepo.FOO + dst = erepo.FOO + "_imported" + + Repo.get(erepo.root_dir, src, dst) + + assert not System.is_symlink(dst) + assert os.path.exists(dst) + assert os.path.isfile(dst) + + def test_get_repo_rev(repo_dir, erepo): src = "version" dst = src