summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeffrey Salmond <js947@users.noreply.github.com>2019-10-01 18:29:10 +0100
committerPeter Scheibel <scheibel1@llnl.gov>2019-10-01 10:29:10 -0700
commit76178f31ca89e81d6f97c3fcf322bd3100322634 (patch)
tree1861c1bbac46ce8611d03359fd24aa07a435aacd /lib
parenta7e64e539699a6b2387ec393f36b511e84833625 (diff)
downloadspack-76178f31ca89e81d6f97c3fcf322bd3100322634.tar.gz
spack-76178f31ca89e81d6f97c3fcf322bd3100322634.tar.bz2
spack-76178f31ca89e81d6f97c3fcf322bd3100322634.tar.xz
spack-76178f31ca89e81d6f97c3fcf322bd3100322634.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/filesystem_view.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py
index 5385ca0803..1701af5501 100644
--- a/lib/spack/spack/filesystem_view.py
+++ b/lib/spack/spack/filesystem_view.py
@@ -357,6 +357,9 @@ class YamlFilesystemView(FilesystemView):
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