1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-11 18:54:00 +00:00

better handle directory updates (fix #36)

This commit is contained in:
Ziirish
2018-06-01 14:07:35 +02:00
parent 018cfd6fe2
commit 6a49b31d35

View File

@@ -197,10 +197,15 @@ def update(opts, conf, path):
return False return False
dotfile = subs[0] dotfile = subs[0]
src = os.path.join(conf.get_abs_dotpath(opts['dotpath']), dotfile.src) src = os.path.join(conf.get_abs_dotpath(opts['dotpath']), dotfile.src)
if Templategen.get_marker() in open(src, 'r').read(): if os.path.isfile(src) and \
Templategen.get_marker() in open(src, 'r').read():
LOG.warn('\"{}\" uses template, please update manually'.format(src)) LOG.warn('\"{}\" uses template, please update manually'.format(src))
return False return False
cmd = ['cp', '-R', '-L', os.path.expanduser(path), src] # Handle directory update
src_clean = src
if os.path.isdir(src):
src_clean = os.path.join(src, '..')
cmd = ['cp', '-R', '-L', os.path.expanduser(path), src_clean]
if opts['dry']: if opts['dry']:
LOG.dry('would run: {}'.format(' '.join(cmd))) LOG.dry('would run: {}'.format(' '.join(cmd)))
else: else: