change source archive caching to omit digest from name and instead calculate and compare the checksum. This achieves the original goal of discarding stale cache files without preserving multiple files for the same version.

This commit is contained in:
Peter Scheibel 2016-06-06 12:26:13 -07:00
parent dd26c0bbcc
commit de1ec4be8b
3 changed files with 22 additions and 18 deletions

View file

@ -343,7 +343,7 @@ def reset(self):
def __repr__(self): def __repr__(self):
url = self.url if self.url else "no url" url = self.url if self.url else "no url"
return "URLFetchStrategy<%s>" % url return "%s<%s>" % (self.__class__.__name__, url)
def __str__(self): def __str__(self):
if self.url: if self.url:
@ -352,6 +352,25 @@ def __str__(self):
return "[no url]" return "[no url]"
class URLMirrorFetchStrategy(URLFetchStrategy):
"""The resource associated with a URL at a mirror may be out of date.
"""
def __init__(self, *args, **kwargs):
super(URLMirrorFetchStrategy, self).__init__(*args, **kwargs)
@_needs_stage
def fetch(self):
super(URLMirrorFetchStrategy, self).fetch()
if self.digest:
try:
self.check()
except ChecksumError:
# Future fetchers will assume they don't need to download if the
# file remains
os.remove(self.archive_file)
raise
class VCSFetchStrategy(FetchStrategy): class VCSFetchStrategy(FetchStrategy):
def __init__(self, name, *rev_types, **kwargs): def __init__(self, name, *rev_types, **kwargs):
super(VCSFetchStrategy, self).__init__() super(VCSFetchStrategy, self).__init__()
@ -816,7 +835,7 @@ def store(self, copyCmd, relativeDst):
def fetcher(self, targetPath, digest): def fetcher(self, targetPath, digest):
url = "file://" + join_path(self.root, targetPath) url = "file://" + join_path(self.root, targetPath)
return URLFetchStrategy(url, digest) return URLMirrorFetchStrategy(url, digest)
class FetchError(spack.error.SpackError): class FetchError(spack.error.SpackError):

View file

@ -61,13 +61,7 @@ def mirror_archive_filename(spec, fetcher):
# Otherwise we'll make a .tar.gz ourselves # Otherwise we'll make a .tar.gz ourselves
ext = 'tar.gz' ext = 'tar.gz'
tokens = [spec.package.name, spec.version] filename = "%s-%s" % (spec.package.name, spec.version)
digests = spec.package.digests
if digests:
# If a package has multiple digests, any one is sufficient to identify it
digestType, digest = sorted(digests.iteritems())[0]
tokens.extend([digestType, digest])
filename = '-'.join(str(t) for t in tokens)
if ext: if ext:
filename += ".%s" % ext filename += ".%s" % ext
return filename return filename

View file

@ -413,15 +413,6 @@ def version(self):
raise ValueError("Can only get of package with concrete version.") raise ValueError("Can only get of package with concrete version.")
return self.spec.versions[0] return self.spec.versions[0]
@property
def digests(self):
"""All digests for the concretized package version."""
versionInfo = self.versions[self.version]
digests = {}
if 'md5' in versionInfo:
digests['md5'] = versionInfo['md5']
return digests
@memoized @memoized
def version_urls(self): def version_urls(self):
"""Return a list of URLs for different versions of this """Return a list of URLs for different versions of this