From b1d2f001687a222893c45a9bf13af1705c9c483a Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 6 Dec 2018 21:10:56 +0900 Subject: source.py: Add new delegate method validate_cache() This is guaranteed to be called only once for a given session once the sources are known to be 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. --- buildstream/source.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'buildstream/source.py') 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 `. +* :func:`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 `, + 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): -- cgit v1.2.1