1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-08 00:24:17 +00:00

improve compare speed

This commit is contained in:
deadc0de6
2020-11-18 15:39:30 +01:00
parent c7671165c3
commit 962cb775d9

View File

@@ -133,19 +133,23 @@ def _dotfile_compare(o, dotfile, tmp):
LOG.dbg('points to itself') LOG.dbg('points to itself')
return True return True
# install dotfile to temporary dir and compare if dotfile.template or Templategen.is_template(src):
ret, err, insttmp = inst.install_to_temp(t, tmp, src, dotfile.dst, # install dotfile to temporary dir for compare
template=dotfile.template, ret, err, insttmp = inst.install_to_temp(t, tmp, src, dotfile.dst,
chmod=dotfile.chmod) template=dotfile.template,
if not ret: chmod=dotfile.chmod)
# failed to install to tmp if not ret:
line = '=> compare {}: error' # failed to install to tmp
LOG.log(line.format(dotfile.key, err)) line = '=> compare {} error: {}'
LOG.err(err) LOG.log(line.format(dotfile.key, err))
return False LOG.err(err)
return False
src = insttmp
# compare
ignores = list(set(o.compare_ignore + dotfile.cmpignore)) ignores = list(set(o.compare_ignore + dotfile.cmpignore))
ignores = patch_ignores(ignores, dotfile.dst, debug=o.debug) 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 # clean tmp transformed dotfile if any
if tmpsrc: if tmpsrc:
@@ -153,6 +157,11 @@ def _dotfile_compare(o, dotfile, tmp):
if os.path.exists(tmpsrc): if os.path.exists(tmpsrc):
removepath(tmpsrc, LOG) removepath(tmpsrc, LOG)
# clean tmp template dotfile if any
if insttmp:
if os.path.exists(insttmp):
removepath(insttmp, LOG)
if diff != '': if diff != '':
# print diff results # print diff results
line = '=> compare {}: diffing with \"{}\"' line = '=> compare {}: diffing with \"{}\"'