From 1bd9e9fbb10c3cb2201a2bc6ac10fa9430945376 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 15 May 2018 22:57:35 +0300 Subject: [PATCH] dvc: print warning when file/dir is empty Fixes #677 Signed-off-by: Ruslan Kuprieiev --- dvc/output.py | 4 ++++ dvc/scm.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dvc/output.py b/dvc/output.py index d32a334f1..95d3f2dea 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -98,6 +98,10 @@ class Dependency(object): if not os.path.isfile(self.path) and not os.path.isdir(self.path): raise CmdOutputIsNotFileOrDirError(self.rel_path) + if (os.path.isfile(self.path) and os.path.getsize(self.path) == 0) or \ + (os.path.isdir(self.path) and len(os.listdir(self.path)) == 0): + self.project.logger.warn("File/directory '{}' is empty.".format(self.rel_path)) + self.md5 = self.project.state.update(self.path) @staticmethod diff --git a/dvc/scm.py b/dvc/scm.py index 79a7572c7..46a95ff9c 100644 --- a/dvc/scm.py +++ b/dvc/scm.py @@ -87,7 +87,7 @@ class Git(Base): gitignore = os.path.abspath(os.path.realpath(gitignore)) if not gitignore.startswith(self.root_dir): - raise FileNotInRepoError() + raise FileNotInRepoError(path) return entry, gitignore