summaryrefslogtreecommitdiff
path: root/buildstream/source.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildstream/source.py')
-rw-r--r--buildstream/source.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index ed4dd9617..24e5b6c5b 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -87,6 +87,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
--------------------------
@@ -487,9 +492,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 #
#############################################################
@@ -649,6 +667,11 @@ class Source(Plugin):
with context.silence():
self.__consistency = self.get_consistency()
+ # 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):