summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-12-13 18:53:08 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-12-13 18:53:08 +0100
commit37141fe491b515beb04bd1d9f016a96154de7c4a (patch)
treed9347dbc26c9e772c5405a5b71dffd581b3e1020
parent646ebd92c8ad9897078746ef440231a2fc34b683 (diff)
parse .diff/Index hashes in reverse order
Reversing the parsing order ensures that we parse weaker hashes (like SHA1) before we touch newer/stronger hashes (like SHA256) as the weaker ones will usually be there for a longer time already with data already present, which we would discard if we start with the strong one first. The discarding is visible in the debug logs: File X wasn't in the list for the first parsed hash! (history) File X wasn't in the list for the first parsed hash! (patches) which if file X is part of the patch-path means apt will not find a path and fallback to acquire the whole file instead needlessly. If file X isn't part of the patch-path that is no problem, so that effects only the update-call which updates with patches coming from before and after the addition of a new hash.
-rw-r--r--apt-pkg/acquire-item.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index e0f02b8e2..54a50ff34 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1837,10 +1837,18 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
std::clog << "Server-Current: " << ServerHashes.find(NULL)->toStr() << " and we start at "
<< CurrentPackagesFile << " " << LocalHashes.FileSize() << " " << LocalHashes.find(NULL)->toStr() << std::endl;
+ // historically, older hashes have more info than newer ones, so start
+ // collecting with older ones first to avoid implementing complicated
+ // information merging techniques… a failure is after all always
+ // recoverable with a complete file and hashes aren't changed that often.
+ std::vector<char const *> types;
+ for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
+ types.push_back(*type);
+
// parse all of (provided) history
vector<DiffInfo> available_patches;
bool firstAcceptedHashes = true;
- for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
+ for (auto type = types.crbegin(); type != types.crend(); ++type)
{
if (LocalHashes.find(*type) == NULL)
continue;
@@ -1898,7 +1906,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
return false;
}
- for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
+ for (auto type = types.crbegin(); type != types.crend(); ++type)
{
if (LocalHashes.find(*type) == NULL)
continue;
@@ -1938,7 +1946,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
}
}
- for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
+ for (auto type = types.crbegin(); type != types.crend(); ++type)
{
std::string tagname = *type;
tagname.append("-Download");