1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-05 06:13:49 +00:00

handle reimport of file within imported directory

This commit is contained in:
deadc0de6
2019-06-24 06:24:36 -04:00
parent 8902cd3cf4
commit 6074ec07b3
2 changed files with 104 additions and 1 deletions

View File

@@ -353,7 +353,21 @@ def cmd_importer(o):
# prepare hierarchy for dotfile
srcf = os.path.join(o.dotpath, src)
if not os.path.exists(srcf):
overwrite = not os.path.exists(srcf)
if o.safe and os.path.exists(srcf):
c = Comparator(debug=o.debug)
diff = c.compare(srcf, dst)
if diff != '':
# files are different, dunno what to do
LOG.log('diff \"{}\" VS \"{}\"'.format(dst, srcf))
LOG.emph(diff)
# ask user
msg = 'Dotfile \"{}\" already exists, overwrite?'.format(srcf)
overwrite = LOG.ask(msg)
if o.debug:
LOG.dbg('will overwrite: {}'.format(overwrite))
if overwrite:
cmd = ['mkdir', '-p', '{}'.format(os.path.dirname(srcf))]
if o.dry:
LOG.dry('would run: {}'.format(' '.join(cmd)))