(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)

This commit is contained in:
Peter Scheibel 2016-06-07 16:26:54 -07:00
parent de1ec4be8b
commit a2754894ea
2 changed files with 15 additions and 3 deletions

View File

@ -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)

View File

@ -337,7 +337,7 @@ def check(self):
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):