Skip to content

Commit f732dcf

Browse files
authored
Merge pull request #615 from efiop/master
dvc: convert paths to POSIX when reading and writing stage files
2 parents 7f32d52 + 1d47bad commit f732dcf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dvc/output.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import json
44
import shutil
55
import schema
6+
import posixpath
7+
import ntpath
68
from checksumdir import dirhash
79

810
from dvc.system import System
@@ -97,15 +99,22 @@ def save(self):
9799

98100
self.md5 = self.project.state.update(self.path)
99101

102+
@staticmethod
103+
def unixpath(path):
104+
assert not ntpath.isabs(path)
105+
assert not posixpath.isabs(path)
106+
return path.replace('\\', '/')
107+
100108
def dumpd(self, cwd):
101109
return {
102-
Output.PARAM_PATH: os.path.relpath(self.path, cwd),
110+
Output.PARAM_PATH: self.unixpath(os.path.relpath(self.path, cwd)),
103111
Output.PARAM_MD5: self.md5,
104112
}
105113

106114
@classmethod
107115
def loadd(cls, project, d, cwd=os.curdir):
108-
path = os.path.join(cwd, d[Output.PARAM_PATH])
116+
relpath = os.path.normpath(Output.unixpath(d[Output.PARAM_PATH]))
117+
path = os.path.join(cwd, relpath)
109118
md5 = d.get(Output.PARAM_MD5, None)
110119
return cls(project, path, md5=md5)
111120

0 commit comments

Comments
 (0)