diff options
Diffstat (limited to 'src/buildstream/plugins/sources/_downloadablefilesource.py')
-rw-r--r-- | src/buildstream/plugins/sources/_downloadablefilesource.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/buildstream/plugins/sources/_downloadablefilesource.py b/src/buildstream/plugins/sources/_downloadablefilesource.py index 4e43ee3e3..50f8561fb 100644 --- a/src/buildstream/plugins/sources/_downloadablefilesource.py +++ b/src/buildstream/plugins/sources/_downloadablefilesource.py @@ -7,7 +7,7 @@ import contextlib import shutil import netrc -from buildstream import Source, SourceError, Consistency +from buildstream import Source, SourceError from buildstream import utils @@ -88,15 +88,8 @@ class DownloadableFileSource(Source): def get_unique_key(self): return [self.original_url, self.ref] - def get_consistency(self): - if self.ref is None: - return Consistency.INCONSISTENT - - if os.path.isfile(self._get_mirror_file()): - return Consistency.CACHED - - else: - return Consistency.RESOLVED + def is_cached(self) -> bool: + return os.path.isfile(self._get_mirror_file()) def load_ref(self, node): self.ref = node.get_str("ref", None) @@ -130,7 +123,7 @@ class DownloadableFileSource(Source): # Just a defensive check, it is impossible for the # file to be already cached because Source.fetch() will - # not be called if the source is already Consistency.CACHED. + # not be called if the source is already cached. # if os.path.isfile(self._get_mirror_file()): return # pragma: nocover @@ -178,7 +171,7 @@ class DownloadableFileSource(Source): etag = self._get_etag(self.ref) # Do not re-download the file if the ETag matches. - if etag and self.get_consistency() == Consistency.CACHED: + if etag and self.is_cached(): request.add_header("If-None-Match", etag) opener = self.__get_urlopener() |