Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ def _download(
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
):
copyfile(
fspath_py35(from_info),
to_file,
no_progress_bar=no_progress_bar,
name=name,
from_info, to_file, no_progress_bar=no_progress_bar, name=name
)

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions dvc/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def copyfile(src, dest, no_progress_bar=False, name=None):
from dvc.progress import Tqdm
from dvc.system import System

src = fspath_py35(src)
dest = fspath_py35(dest)

name = name if name else os.path.basename(dest)
total = os.stat(src).st_size

Expand Down
29 changes: 29 additions & 0 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import filecmp
import os

import pytest

from dvc.path_info import PathInfo
from dvc.utils import copyfile
from dvc.utils import file_md5
from dvc.utils import fix_env
from dvc.utils import to_chunks
from tests.basic_env import TestDir


@pytest.mark.parametrize(
Expand Down Expand Up @@ -79,3 +82,29 @@ def test_file_md5(repo_dir):
fname = repo_dir.FOO
fname_object = PathInfo(fname)
assert file_md5(fname) == file_md5(fname_object)


@pytest.mark.parametrize("path", [TestDir.DATA, TestDir.DATA_DIR])
def test_copyfile(path, repo_dir):
src = repo_dir.FOO
dest = path
src_info = PathInfo(repo_dir.BAR)
dest_info = PathInfo(path)

copyfile(src, dest)
if os.path.isdir(dest):
assert filecmp.cmp(
src, os.path.join(dest, os.path.basename(src)), shallow=False
)
else:
assert filecmp.cmp(src, dest, shallow=False)

copyfile(src_info, dest_info)
if os.path.isdir(dest_info.fspath):
assert filecmp.cmp(
src_info.fspath,
os.path.join(dest_info.fspath, os.path.basename(src_info.fspath)),
shallow=False,
)
else:
assert filecmp.cmp(src_info.fspath, dest_info.fspath, shallow=False)