From fcc17c820d676b82dc2536c270bbfc3c28abfba1 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 30 Aug 2018 14:54:46 +0900 Subject: source.py: Stylistic changes in Source.__do_fetch() Added some comments to make the flow easier to follow, and removed an annoying 'success' variabled in favor of a for / else loop statement. --- buildstream/source.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/buildstream/source.py b/buildstream/source.py index a9ae090a5..5e43da5ea 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -865,10 +865,12 @@ class Source(Plugin): def __do_fetch(self, **kwargs): project = self._get_project() source_fetchers = self.get_source_fetchers() + + # Use the source fetchers if they are provided + # if source_fetchers: for fetcher in source_fetchers: alias = fetcher._get_alias() - success = False for uri in project.get_alias_uris(alias, first_pass=self.__first_pass): try: fetcher.fetch(uri) @@ -877,10 +879,16 @@ class Source(Plugin): except BstError as e: last_error = e continue - success = True + + # No error, we're done with this fetcher break - if not success: + + else: + # No break occurred, raise the last detected error raise last_error + + # Default codepath is to reinstantiate the Source + # else: alias = self._get_alias() if self.__first_pass: @@ -904,7 +912,11 @@ class Source(Plugin): except BstError as e: last_error = e continue + + # No error, we're done here return + + # Re raise the last detected error raise last_error # Tries to call track for every mirror, stopping once it succeeds -- cgit v1.2.1