mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 17:24:46 +00:00
improve compare speed
This commit is contained in:
@@ -133,19 +133,23 @@ def _dotfile_compare(o, dotfile, tmp):
|
||||
LOG.dbg('points to itself')
|
||||
return True
|
||||
|
||||
# install dotfile to temporary dir and compare
|
||||
ret, err, insttmp = inst.install_to_temp(t, tmp, src, dotfile.dst,
|
||||
template=dotfile.template,
|
||||
chmod=dotfile.chmod)
|
||||
if not ret:
|
||||
# failed to install to tmp
|
||||
line = '=> compare {}: error'
|
||||
LOG.log(line.format(dotfile.key, err))
|
||||
LOG.err(err)
|
||||
return False
|
||||
if dotfile.template or Templategen.is_template(src):
|
||||
# install dotfile to temporary dir for compare
|
||||
ret, err, insttmp = inst.install_to_temp(t, tmp, src, dotfile.dst,
|
||||
template=dotfile.template,
|
||||
chmod=dotfile.chmod)
|
||||
if not ret:
|
||||
# failed to install to tmp
|
||||
line = '=> compare {} error: {}'
|
||||
LOG.log(line.format(dotfile.key, err))
|
||||
LOG.err(err)
|
||||
return False
|
||||
src = insttmp
|
||||
|
||||
# compare
|
||||
ignores = list(set(o.compare_ignore + dotfile.cmpignore))
|
||||
ignores = patch_ignores(ignores, dotfile.dst, debug=o.debug)
|
||||
diff = comp.compare(insttmp, dotfile.dst, ignore=ignores)
|
||||
diff = comp.compare(src, dotfile.dst, ignore=ignores)
|
||||
|
||||
# clean tmp transformed dotfile if any
|
||||
if tmpsrc:
|
||||
@@ -153,6 +157,11 @@ def _dotfile_compare(o, dotfile, tmp):
|
||||
if os.path.exists(tmpsrc):
|
||||
removepath(tmpsrc, LOG)
|
||||
|
||||
# clean tmp template dotfile if any
|
||||
if insttmp:
|
||||
if os.path.exists(insttmp):
|
||||
removepath(insttmp, LOG)
|
||||
|
||||
if diff != '':
|
||||
# print diff results
|
||||
line = '=> compare {}: diffing with \"{}\"'
|
||||
|
||||
Reference in New Issue
Block a user