summaryrefslogtreecommitdiff
path: root/src/buildstream/source.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-08-04 16:49:10 +0200
committerJürg Billeter <j@bitron.ch>2020-08-06 07:10:28 +0200
commit5c1468e7ebfeddb695eb754b606099468dcea98a (patch)
treead590bb977ce537425564e7451bee3b8df868de7 /src/buildstream/source.py
parent7a9dd098efa6d5070455f432e2557a321b2dfd76 (diff)
downloadbuildstream-5c1468e7ebfeddb695eb754b606099468dcea98a.tar.gz
source.py: Validate cache when it's used, not in `_is_cached()`
`_is_cached()` is indirectly called by the frontend, which is not optimal for handling per-plugin errors. Instead, call `validate_cache()` right before the cache is used: in fetch jobs and when opening a workspace.
Diffstat (limited to 'src/buildstream/source.py')
-rw-r--r--src/buildstream/source.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index f15d5a628..4c284a57c 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -539,10 +539,10 @@ class Source(Plugin):
"""Implement any validations once we know the sources are cached
This is guaranteed to be called only once for a given session
- once the sources are known to be cached.
- If source tracking is enabled in the session for this source,
- then this will only be called if the sources become cached after
- tracking completes.
+ once the sources are known to be cached, before
+ :func:`Source.stage() <buildstream.source.Source.stage>` or
+ :func:`Source.init_workspace() <buildstream.source.Source.init_workspace>`
+ is called.
"""
def is_cached(self) -> bool:
@@ -780,9 +780,6 @@ class Source(Plugin):
reason="source-bug",
)
- if self.__is_cached:
- self.validate_cache()
-
return self.__is_cached
# Wrapper function around plugin provided fetch method
@@ -800,8 +797,6 @@ class Source(Plugin):
else:
self.__do_fetch()
- self.validate_cache()
-
# _fetch_done()
#
# Indicates that fetching the source has been done.
@@ -831,6 +826,7 @@ class Source(Plugin):
cas_dir = CasBasedDirectory(self._get_context().get_cascache(), digest=self.__digest)
directory.import_files(cas_dir)
else:
+ self.validate_cache()
self.stage(directory)
# Wrapper for init_workspace()
@@ -840,6 +836,7 @@ class Source(Plugin):
directory = self.__ensure_directory(directory)
+ self.validate_cache()
self.init_workspace(directory)
# _get_unique_key():