From a3aefe5f165d06f5defa6b22a9a02d4394128216 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 31 Aug 2018 22:25:20 +0300 Subject: [PATCH] state: don't forget subdirs when computing effective mtime Signed-off-by: Ruslan Kuprieiev --- dvc/state.py | 6 +++--- tests/test_repro.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dvc/state.py b/dvc/state.py index 56d6fadb5..f17b82d49 100644 --- a/dvc/state.py +++ b/dvc/state.py @@ -99,9 +99,9 @@ class State(object): mtime = os.path.getmtime(path) if os.path.isdir(path): for root, dirs, files in os.walk(path): - for fname in files: - f = os.path.join(root, fname) - m = os.path.getmtime(f) + for entry in list(dirs) + list(files): + p = os.path.join(root, entry) + m = os.path.getmtime(p) if m > mtime: mtime = m diff --git a/tests/test_repro.py b/tests/test_repro.py index bb84cff50..a38d3ccf2 100644 --- a/tests/test_repro.py +++ b/tests/test_repro.py @@ -18,6 +18,7 @@ from dvc.project import Project, ReproductionError from dvc.utils import file_md5 from dvc.remote.local import RemoteLOCAL from dvc.stage import Stage, StageFileDoesNotExistError +from dvc.system import System from tests.basic_env import TestDvc from tests.test_data_cloud import _should_test_aws, TEST_AWS_REPO_BUCKET @@ -296,6 +297,13 @@ class TestReproChangedDirData(TestDvc): self.assertEqual(len(stages), 1) self.assertTrue(stages[0] is not None) + # Check that dvc registers mtime change for the directory. + System.hardlink(self.DATA_SUB, self.DATA_SUB + '.lnk') + sleep() + stages = self.dvc.reproduce(stage.path) + self.assertEqual(len(stages), 1) + self.assertTrue(stages[0] is not None) + class TestReproMissingMd5InStageFile(TestRepro): def test(self):