diff options
-rw-r--r-- | buildstream/source.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/buildstream/source.py b/buildstream/source.py index 5dc5abb63..bb54110ca 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -102,6 +102,11 @@ these methods are mandatory to implement. submodules). For details on how to define a SourceFetcher, see :ref:`SourceFetcher <core_source_fetcher>`. +* :func:`Source.validate_cache() <buildstream.source.Source.validate_cache>` + + Perform any validations which require the sources to be cached. + + **Optional**: This is completely optional and will do nothing if left unimplemented. Accessing previous sources -------------------------- @@ -480,9 +485,22 @@ class Source(Plugin): *Since: 1.2* """ - return [] + def validate_cache(self): + """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 + :attr:`Consistency.CACHED <buildstream.types.Consistency.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. + + *Since: 1.4* + """ + pass + ############################################################# # Public Methods # ############################################################# @@ -659,6 +677,11 @@ class Source(Plugin): with context.silence(): self.__consistency = self.get_consistency() # pylint: disable=assignment-from-no-return + # Give the Source an opportunity to validate the cached + # sources as soon as the Source becomes Consistency.CACHED. + if self.__consistency == Consistency.CACHED: + self.validate_cache() + # Return cached consistency # def _get_consistency(self): |