From a2754894ea67e0e751121411ff92d60ca68ab089 Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Tue, 7 Jun 2016 16:26:54 -0700 Subject: (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) --- lib/spack/spack/fetch_strategy.py | 16 ++++++++++++++-- lib/spack/spack/stage.py | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'lib') 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): -- cgit v1.2.3-70-g09d2