1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 20:19:46 +00:00

ensure source dotfile exists

This commit is contained in:
deadc0de6
2018-09-24 22:02:36 +02:00
parent 0d4ce18e49
commit d36e525ca4
3 changed files with 8 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ class Comparator:
def _comp_dir(self, left, right, ignore):
"""compare a directory"""
if not os.path.exists(right):
return ''
if self._ignore([left, right], ignore):
if self.debug:
self.log.dbg('ignoring diff {} and {}'.format(left, right))

View File

@@ -36,6 +36,8 @@ class Installer:
def install(self, templater, src, dst):
"""install the src to dst using a template"""
src = os.path.join(self.base, os.path.expanduser(src))
if not os.path.exists(src):
self.log.err('source dotfile does not exist: {}'.format(src))
dst = os.path.expanduser(dst)
if self.totemp:
dst = self._pivot_path(dst, self.totemp)
@@ -52,6 +54,8 @@ class Installer:
def link(self, templater, src, dst):
"""set src as the link target of dst"""
src = os.path.join(self.base, os.path.expanduser(src))
if not os.path.exists(src):
self.log.err('source dotfile does not exist: {}'.format(src))
dst = os.path.expanduser(dst)
if self.totemp:
return self.install(templater, src, dst)

View File

@@ -93,6 +93,8 @@ class Templategen:
def is_template(path):
"""recursively check if any file is a template within path"""
if not os.path.exists(path):
return False
if os.path.isfile(path):
# is file
return Templategen._is_template(path)