diff --git a/dvc/remote/local.py b/dvc/remote/local.py index 0197ec53ef..286d150993 100644 --- a/dvc/remote/local.py +++ b/dvc/remote/local.py @@ -149,7 +149,7 @@ def walk_files(self, path_info): yield PathInfo(fname) def get_file_checksum(self, path_info): - return file_md5(fspath_py35(path_info))[0] + return file_md5(path_info)[0] def remove(self, path_info): if path_info.scheme != "local": diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index d8fd1fae18..c95e4dff67 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -44,6 +44,8 @@ def file_md5(fname): from dvc.progress import Tqdm from dvc.istextfile import istextfile + fname = fspath_py35(fname) + if os.path.exists(fname): hash_md5 = hashlib.md5() binary = not istextfile(fname) diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 59f801af08..8cf5ee9933 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -2,6 +2,8 @@ import pytest +from dvc.path_info import PathInfo +from dvc.utils import file_md5 from dvc.utils import fix_env from dvc.utils import to_chunks @@ -71,3 +73,9 @@ def test_fix_env_pyenv(path, orig): "PYENV_HOOK_PATH": "/some/hook/path", } assert fix_env(env)["PATH"] == orig + + +def test_file_md5(repo_dir): + fname = repo_dir.FOO + fname_object = PathInfo(fname) + assert file_md5(fname) == file_md5(fname_object)