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
9 changes: 4 additions & 5 deletions dvc/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,13 @@ def save_link(self, path_info):
path_info (dict): path info to add to the list of links.
"""
assert path_info.scheme == "local"
path = fspath_py35(path_info)

if not os.path.exists(path):
if not os.path.exists(fspath_py35(path_info)):
return

mtime, _ = get_mtime_and_size(path, self.repo.tree)
inode = get_inode(path)
relative_path = relpath(path, self.root_dir)
mtime, _ = get_mtime_and_size(path_info, self.repo.tree)
inode = get_inode(path_info)
relative_path = relpath(path_info, self.root_dir)

cmd = "REPLACE INTO {}(path, inode, mtime) " "VALUES (?, ?, ?)".format(
self.LINK_STATE_TABLE
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dvc.utils import file_md5
from dvc.utils import fix_env
from dvc.utils import makedirs
from dvc.utils import relpath
from dvc.utils import to_chunks
from dvc.utils import tmp_fname
from tests.basic_env import TestDir
Expand Down Expand Up @@ -139,3 +140,10 @@ def pattern(path):
tmp_fname(file_path_info),
re.IGNORECASE,
)


def test_relpath():
path = "path"
path_info = PathInfo(path)

assert relpath(path) == relpath(path_info)