link_tree: only remove matching files when unmerging

This commit is contained in:
Oliver Breitwieser 2017-09-15 08:55:12 -04:00 committed by scheibelp
parent b9e8402104
commit 94c0740a88

View File

@ -26,6 +26,7 @@
import os
import shutil
import filecmp
from llnl.util.filesystem import traverse_tree, mkdirp, touch
@ -113,4 +114,8 @@ def unmerge(self, dest_root, **kwargs):
elif os.path.exists(dest):
if not os.path.islink(dest):
raise ValueError("%s is not a link tree!" % dest)
os.remove(dest)
# remove if dest is a hardlink/symlink to src; this will only
# be false if two packages are merged into a prefix and have a
# conflicting file
if filecmp.cmp(src, dest, shallow=True):
os.remove(dest)