summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-10-27 18:39:36 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2018-01-03 18:55:41 +0100
commit57fa854e4cdb060e87ca265abd5a83364f9fa681 (patch)
treef360e6166d8c5352e3954a0c9129b57a3dcfaf69 /apt-pkg
parentef9677831f62a1554a888ebc7b162517d7881116 (diff)
reimplement and simplify mirror:// method
Embedding an entire acquire stack and HTTP logic in the mirror method made it rather heavy weight and fragile. This reimplement goes the other way by doing only the bare minimum in the method itself and instead redirect the actual download of files to their proper methods. The reimplementation drops the (in the real world) unused query-string feature as it isn't really implementable in the new architecture.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-worker.cc25
1 files changed, 6 insertions, 19 deletions
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 1b1f4dc4c..016aebdcd 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -308,6 +308,7 @@ bool pkgAcquire::Worker::RunMessages()
std::string const NewURI = LookupTag(Message,"New-URI",URI.c_str());
Itm->URI = NewURI;
+ auto const AltUris = VectorizeString(LookupTag(Message, "Alternate-URIs"), '\n');
ItemDone();
@@ -335,28 +336,14 @@ bool pkgAcquire::Worker::RunMessages()
if (Log != nullptr)
Log->Done(desc);
- // if we change site, treat it as a mirror change
- if (URI::SiteOnly(NewURI) != URI::SiteOnly(desc.URI))
- {
- auto const firstSpace = desc.Description.find(" ");
- if (firstSpace != std::string::npos)
- {
- std::string const OldSite = desc.Description.substr(0, firstSpace);
- if (likely(APT::String::Startswith(desc.URI, OldSite)))
- {
- std::string const OldExtra = desc.URI.substr(OldSite.length() + 1);
- if (likely(APT::String::Endswith(NewURI, OldExtra)))
- {
- std::string const NewSite = NewURI.substr(0, NewURI.length() - OldExtra.length());
- Owner->UsedMirror = URI::ArchiveOnly(NewSite);
- desc.Description.replace(0, firstSpace, Owner->UsedMirror);
- }
- }
- }
- }
+ ChangeSiteIsMirrorChange(NewURI, desc, Owner);
desc.URI = NewURI;
if (isDoomedItem(Owner) == false)
+ {
+ for (auto alt = AltUris.crbegin(); alt != AltUris.crend(); ++alt)
+ Owner->PushAlternativeURI(std::string(*alt), {}, false);
OwnerQ->Owner->Enqueue(desc);
+ }
}
break;
}