From 789b2e0b5b9b830819d26bb485a72cbb77f41ef2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 4 Jan 2018 18:33:25 -0800 Subject: [PATCH] Bugfix: do not touch cache file if it does not exist --- dvc/stage.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dvc/stage.py b/dvc/stage.py index 27b4eb9c0..749555df3 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -178,6 +178,16 @@ class Output(object): return stage return None + def remove(self): + if not os.path.exists(self.path): + return + + self.project.logger.debug("Removing '{}'".format(self.path)) + os.chmod(self.path, stat.S_IWUSR) + os.unlink(self.path) + if os.path.exists(self.cache): + os.chmod(self.cache, stat.S_IREAD) + class Dependency(Output): pass @@ -224,11 +234,7 @@ class Stage(object): def remove_outs(self): for out in self.outs: - if os.path.exists(out.path): - self.project.logger.debug("Removing '{}'".format(out.path)) - os.chmod(out.path, stat.S_IWUSR) - os.unlink(out.path) - os.chmod(out.cache, stat.S_IREAD) + out.remove() def remove(self): self.remove_outs()