From b2de95ebb267de18f340459daf92690dc6650e93 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 25 Dec 2017 01:42:42 -0800 Subject: [PATCH] Bugfix: dvc repro - check if files exist before actions --- dvc/stage.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dvc/stage.py b/dvc/stage.py index 0fe8a57c2..e7dfd185e 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -31,7 +31,9 @@ class Output(object): if not self.use_cache: changed = self._changed_md5() else: - changed = not os.path.samefile(self.path, self.cache) + changed = os.path.exists(self.path) \ + and os.path.exists(self.cache) \ + and not os.path.samefile(self.path, self.cache) if changed: self.project.logger.debug('{} changed'.format(self.path)) @@ -173,8 +175,9 @@ class Stage(object): def remove_outs(self): for out in self.outs: - self.project.logger.debug("Removing '{}'".format(out.path)) - os.unlink(out.path) + if os.path.exists(out.path): + self.project.logger.debug("Removing '{}'".format(out.path)) + os.unlink(out.path) def remove(self): self.remove_outs()