dvc: properly compute mtime of the directory

Fixes #1067

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-08-29 19:17:50 +03:00
parent 3574c8954b
commit ac80d59704
2 changed files with 7 additions and 5 deletions
+1 -5
View File
@@ -96,18 +96,14 @@ class State(object):
@staticmethod
def mtime(path):
mtime = os.path.getmtime(path)
if os.path.isdir(path):
mtime = -1
for root, dirs, files in os.walk(path):
for fname in files:
f = os.path.join(root, fname)
m = os.path.getmtime(f)
if m > mtime:
mtime = m
if mtime == -1:
mtime = os.path.getmtime(path)
else:
mtime = os.path.getmtime(path)
return str(int(nanotime.timestamp(mtime)))
+6
View File
@@ -281,6 +281,12 @@ class TestReproChangedDirData(TestDvc):
self.assertEqual(len(stages), 1)
self.assertTrue(stages[0] is not None)
# Check that dvc indeed registers changed output dir
shutil.move(self.BAR, dir_name)
stages = self.dvc.reproduce(stage.path)
self.assertEqual(len(stages), 1)
self.assertTrue(stages[0] is not None)
class TestReproMissingMd5InStageFile(TestRepro):
def test(self):