summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Josef Scheibel <scheibel1@llnl.gov>2019-11-26 18:42:21 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-23 23:03:09 -0800
commit64209dda977c907da435faed6c9e030a50c520ab (patch)
tree7aaf2b2253a16c680a6d39665e9f26bd5d937820 /lib
parentc15e55c6686dc5640f36e833902b9ce3889bb13b (diff)
downloadspack-64209dda977c907da435faed6c9e030a50c520ab.tar.gz
spack-64209dda977c907da435faed6c9e030a50c520ab.tar.bz2
spack-64209dda977c907da435faed6c9e030a50c520ab.tar.xz
spack-64209dda977c907da435faed6c9e030a50c520ab.zip
Allow repeated invocations of 'mirror create'
When creating a cosmetic symlink for a resource in a mirror, remove it if it already exists. The symlink is removed in case the logic to create the symlink has changed.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/caches.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/spack/spack/caches.py b/lib/spack/spack/caches.py
index a7910905bc..61a47eaa6e 100644
--- a/lib/spack/spack/caches.py
+++ b/lib/spack/spack/caches.py
@@ -70,7 +70,13 @@ class MirrorCache(object):
relative_dst = os.path.relpath(
mirror_ref.storage_path,
start=os.path.dirname(cosmetic_path))
+
if not os.path.exists(cosmetic_path):
+ if os.path.lexists(cosmetic_path):
+ # In this case the link itself exists but it is broken: remove
+ # it and recreate it (in order to fix any symlinks broken prior
+ # to https://github.com/spack/spack/pull/13908)
+ os.unlink(cosmetic_path)
mkdirp(os.path.dirname(cosmetic_path))
os.symlink(relative_dst, cosmetic_path)