When removing a file from a view, don't fail if it doesn't exist (#12960)
Sometimes when remove_file is called on a link, that link is missing (perhaps ctrl-C happened halfway through a previous action). As removing a non-existent file is no problem, this patch changes the behavior so Spack continues rather than stopping with an error. Currently you would see ValueError: /path/to/dir is not a link tree! and now it continues with a warning.
This commit is contained in:
parent
a7e64e5396
commit
76178f31ca
@ -357,6 +357,9 @@ def unmerge(self, spec, ignore=None):
|
||||
tree.unmerge_directories(view_dst, ignore_file)
|
||||
|
||||
def remove_file(self, src, dest):
|
||||
if not os.path.lexists(dest):
|
||||
tty.warn("Tried to remove %s which does not exist" % dest)
|
||||
return
|
||||
if not os.path.islink(dest):
|
||||
raise ValueError("%s is not a link tree!" % dest)
|
||||
# remove if dest is a hardlink/symlink to src; this will only
|
||||
|
Loading…
Reference in New Issue
Block a user