... |
... |
@@ -620,12 +620,8 @@ class Source(Plugin): |
620
|
620
|
self.fetch()
|
621
|
621
|
return
|
622
|
622
|
|
623
|
|
- context = self._get_context()
|
624
|
|
- source_kind = type(self)
|
625
|
623
|
for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
|
626
|
|
- new_source = source_kind(context, project, self.__meta,
|
627
|
|
- alias_override=(alias, uri))
|
628
|
|
- new_source._preflight()
|
|
624
|
+ new_source = self.__clone_for_uri(uri)
|
629
|
625
|
try:
|
630
|
626
|
new_source.fetch()
|
631
|
627
|
# FIXME: Need to consider temporary vs. permanent failures,
|
... |
... |
@@ -878,6 +874,38 @@ class Source(Plugin): |
878
|
874
|
# Local Private Methods #
|
879
|
875
|
#############################################################
|
880
|
876
|
|
|
877
|
+ # __clone_for_uri()
|
|
878
|
+ #
|
|
879
|
+ # Clone the source with an alternative URI setup for the alias
|
|
880
|
+ # which this source uses.
|
|
881
|
+ #
|
|
882
|
+ # This is used for iteration over source mirrors.
|
|
883
|
+ #
|
|
884
|
+ # Args:
|
|
885
|
+ # uri (str): The alternative URI for this source's alias
|
|
886
|
+ #
|
|
887
|
+ # Returns:
|
|
888
|
+ # (Source): A new clone of this Source, with the specified URI
|
|
889
|
+ # as the value of the alias this Source has marked as
|
|
890
|
+ # primary with either mark_download_url() or
|
|
891
|
+ # translate_url().
|
|
892
|
+ #
|
|
893
|
+ def __clone_for_uri(self, uri):
|
|
894
|
+ project = self._get_project()
|
|
895
|
+ context = self._get_context()
|
|
896
|
+ alias = self._get_alias()
|
|
897
|
+ source_kind = type(self)
|
|
898
|
+
|
|
899
|
+ clone = source_kind(context, project, self.__meta, alias_override=(alias, uri))
|
|
900
|
+
|
|
901
|
+ # Do the necessary post instantiation routines here
|
|
902
|
+ #
|
|
903
|
+ clone._preflight()
|
|
904
|
+ clone._load_ref()
|
|
905
|
+ clone._update_state()
|
|
906
|
+
|
|
907
|
+ return clone
|
|
908
|
+
|
881
|
909
|
# Tries to call track for every mirror, stopping once it succeeds
|
882
|
910
|
def __do_track(self):
|
883
|
911
|
project = self._get_project()
|
... |
... |
@@ -890,15 +918,10 @@ class Source(Plugin): |
890
|
918
|
if not mirrors or not alias:
|
891
|
919
|
return self.track()
|
892
|
920
|
|
893
|
|
- context = self._get_context()
|
894
|
|
- source_kind = type(self)
|
895
|
|
-
|
896
|
921
|
# NOTE: We are assuming here that tracking only requires substituting the
|
897
|
922
|
# first alias used
|
898
|
923
|
for uri in reversed(project.get_alias_uris(alias, first_pass=self.__first_pass)):
|
899
|
|
- new_source = source_kind(context, project, self.__meta,
|
900
|
|
- alias_override=(alias, uri))
|
901
|
|
- new_source._preflight()
|
|
924
|
+ new_source = self.__clone_for_uri(uri)
|
902
|
925
|
try:
|
903
|
926
|
ref = new_source.track()
|
904
|
927
|
# FIXME: Need to consider temporary vs. permanent failures,
|