From cccda6e2844e0dffa28e86117588eebb9b47ec6d Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Fri, 29 Jan 2021 21:45:32 +0100 Subject: [PATCH] fail early when profile does not exist (#300) --- dotdrop/dotdrop.py | 4 ++++ dotdrop/updater.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 1b81240..47b9679 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -419,6 +419,10 @@ def cmd_update(o): paths = o.update_path iskey = o.update_iskey + if o.profile not in [p.key for p in o.profiles]: + LOG.err('no such profile \"{}\"'.format(o.profile)) + return False + adapt_workers(o, LOG) if not paths: diff --git a/dotdrop/updater.py b/dotdrop/updater.py index 37c6dd0..cd9ad6f 100644 --- a/dotdrop/updater.py +++ b/dotdrop/updater.py @@ -95,6 +95,16 @@ class Updater: dtpath = os.path.join(self.dotpath, dotfile.src) dtpath = os.path.expanduser(dtpath) + if not os.path.exists(path): + msg = '\"{}\" does not exist' + self.log.err(msg.format(path)) + return False + + if not os.path.exists(dtpath): + msg = '\"{}\" does not exist, import it first' + self.log.err(msg.format(dtpath)) + return False + if self._ignore([path, dtpath]): self.log.sub('\"{}\" ignored'.format(dotfile.key)) return True