(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:
parent
de1ec4be8b
commit
a2754894ea
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user