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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ neatlynx/__pycache__
cache
*.pyc
.env/
.env2.7/

cache
.dvc.conf.lock
Expand Down
8 changes: 3 additions & 5 deletions dvc/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,12 @@ def save(self, path_info, checksum):
"""
assert path_info.scheme == "local"
assert checksum is not None

path = fspath_py35(path_info)
assert os.path.exists(path)
assert os.path.exists(fspath_py35(path_info))

actual_mtime, actual_size = get_mtime_and_size(
path, self.repo.dvcignore
path_info, self.repo.dvcignore
)
actual_inode = get_inode(path)
actual_inode = get_inode(path_info)

existing_record = self.get_state_record_for_inode(actual_inode)
if not existing_record:
Expand Down
6 changes: 3 additions & 3 deletions dvc/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from dvc.exceptions import DvcException
from dvc.system import System
from dvc.utils import dict_md5, walk_files
from dvc.utils import dict_md5, walk_files, fspath_py35
from dvc.utils.compat import str


Expand All @@ -21,7 +21,7 @@ def get_inode(path):


def get_mtime_and_size(path, dvcignore):
if os.path.isdir(path):
if os.path.isdir(fspath_py35(path)):
size = 0
files_mtimes = {}
for file_path in walk_files(path, dvcignore):
Expand All @@ -39,7 +39,7 @@ def get_mtime_and_size(path, dvcignore):
# max(mtime(f) for f in non_ignored_files)
mtime = dict_md5(files_mtimes)
else:
base_stat = os.stat(path)
base_stat = os.stat(fspath_py35(path))
size = base_stat.st_size
mtime = base_stat.st_mtime
mtime = int(nanotime.timestamp(mtime))
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/utils/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,14 @@ def test_get_inode(repo_dir):
path = repo_dir.FOO
path_info = PathInfo(path)
assert get_inode(path) == get_inode(path_info)


@pytest.mark.parametrize("path", [TestDir.DATA, TestDir.DATA_DIR])
def test_path_object_and_str_are_valid_types_get_mtime_and_size(
path, repo_dir
):
dvcignore = DvcIgnoreFilter(repo_dir.root_dir)
time, size = get_mtime_and_size(path, dvcignore)
object_time, object_size = get_mtime_and_size(PathInfo(path), dvcignore)
assert time == object_time
assert size == object_size