summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2016-06-07 16:26:54 -0700
committerPeter Scheibel <scheibel1@llnl.gov>2016-06-07 16:26:54 -0700
commita2754894ea67e0e751121411ff92d60ca68ab089 (patch)
tree27879e91d540744c3766e0ff5aaaef1c0776be16 /lib
parentde1ec4be8b0c7bc8c36e88a460e64b3be38cff35 (diff)
downloadspack-a2754894ea67e0e751121411ff92d60ca68ab089.tar.gz
spack-a2754894ea67e0e751121411ff92d60ca68ab089.tar.bz2
spack-a2754894ea67e0e751121411ff92d60ca68ab089.tar.xz
spack-a2754894ea67e0e751121411ff92d60ca68ab089.zip
(1) FsCache store now takes a fetcher vs. just a copy command (2) use [1] to conditionally cache resource: only save it if there is a feature which identifies it uniquely (for example do not cache a repository if it pulls the latest state vs. a particular tag/commit)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py16
-rw-r--r--lib/spack/spack/stage.py2
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index fde2a8805e..3221716b91 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -828,10 +828,22 @@ class FsCache(object):
def __init__(self, root):
self.root = os.path.abspath(root)
- def store(self, copyCmd, relativeDst):
+ def store(self, fetcher, relativeDst):
+ unique = False
+ uidGroups = [['tag', 'commit'], ['digest'], ['revision']]
+ for grp in uidGroups:
+ try:
+ unique |= any(getattr(fetcher, x) for x in grp)
+ except AttributeError:
+ pass
+ if unique:
+ break
+ if not unique:
+ return
+
dst = join_path(self.root, relativeDst)
mkdirp(os.path.dirname(dst))
- copyCmd(dst)
+ fetcher.archive(dst)
def fetcher(self, targetPath, digest):
url = "file://" + join_path(self.root, targetPath)
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index f28934d10a..b08cce43b8 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -337,7 +337,7 @@ class Stage(object):
def cache_local(self):
- spack.cache.store(self.fetcher.archive, self.mirror_path)
+ spack.cache.store(self.fetcher, self.mirror_path)
def expand_archive(self):