summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Kuhn <michael.kuhn@informatik.uni-hamburg.de>2018-12-19 14:08:39 +0100
committerPeter Scheibel <scheibel1@llnl.gov>2019-01-04 17:04:28 -0800
commit41ef02ee1009a86d040314433a3823ca3dd13a02 (patch)
treeac00e47730cb933ae07fd0d6eecdbbf89ef947be /lib
parent5450303c975e34265f6fda3c014b9aed7d002a3c (diff)
downloadspack-41ef02ee1009a86d040314433a3823ca3dd13a02.tar.gz
spack-41ef02ee1009a86d040314433a3823ca3dd13a02.tar.bz2
spack-41ef02ee1009a86d040314433a3823ca3dd13a02.tar.xz
spack-41ef02ee1009a86d040314433a3823ca3dd13a02.zip
stage: fix resources being deleted from local cache (#10152)
Non-expanded resources were being deleted from the cache on account of two behaviors: * ResourceStage was moving files rather than copying them, and uses "os.path.realpath" to resolve symlinks * CacheFetchStrategy creates a symlink to a cached resource rather than copying it This alters the first behavior: ResourceStage now copies the file rather than moving it.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/stage.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 2e02abd9b4..b337ae5617 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -8,7 +8,6 @@ import stat
import sys
import errno
import hashlib
-import shutil
import tempfile
import getpass
from six import string_types
@@ -16,7 +15,7 @@ from six import iteritems
from six.moves.urllib.parse import urljoin
import llnl.util.tty as tty
-from llnl.util.filesystem import mkdirp, can_access
+from llnl.util.filesystem import mkdirp, can_access, copy, copy_tree
from llnl.util.filesystem import remove_if_dead_link, remove_linked_tree
import spack.paths
@@ -406,7 +405,7 @@ class Stage(object):
self.fetcher = fetcher
self.fetcher.fetch()
break
- except spack.fetch_strategy.NoCacheError as e:
+ except spack.fetch_strategy.NoCacheError:
# Don't bother reporting when something is not cached.
continue
except spack.error.SpackError as e:
@@ -545,7 +544,13 @@ class ResourceStage(Stage):
'{stage}\n\tdestination : {destination}'.format(
stage=source_path, destination=destination_path
))
- shutil.move(os.path.realpath(source_path), destination_path)
+
+ src = os.path.realpath(source_path)
+
+ if os.path.isdir(src):
+ copy_tree(src, destination_path)
+ else:
+ copy(src, destination_path)
@pattern.composite(method_list=[