diff options
| author | David Kalnischkies <david@kalnischkies.de> | 2022-04-01 11:37:26 +0200 |
|---|---|---|
| committer | David Kalnischkies <david@kalnischkies.de> | 2022-04-01 14:16:19 +0200 |
| commit | 05fae6fae95d8ef6690f3d56863e3bb6a44d424c (patch) | |
| tree | c948709ce9b2e4f4bc6e11138c3c21671d3baf37 /apt-pkg/indexcopy.cc | |
| parent | 472376be6818b5ea43250abcbecfcab53b4a729a (diff) | |
Parse Checksum fields via pkgTagSection::Key, too
We abstract hashes a fair bit to be able to add new ones eventually,
which lead us to building the field names on the fly. We can do better
through by keeping a central place for these names, too, which even
helps in reducing code as we don't need the MD5 → Files dance anymore.
Diffstat (limited to 'apt-pkg/indexcopy.cc')
| -rw-r--r-- | apt-pkg/indexcopy.cc | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 82baba337..0d569265d 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -437,22 +437,14 @@ bool PackageCopy::RewriteEntry(FileFd &Target,string const &File) /* */ bool SourceCopy::GetFile(string &File,unsigned long long &Size) { - string Files; - - for (char const *const *type = HashString::SupportedHashes(); *type != NULL; ++type) + std::string Files; + for (auto hashinfo : HashString::SupportedHashesInfo()) { - // derive field from checksum type - std::string checksumField("Checksums-"); - if (strcmp(*type, "MD5Sum") == 0) - checksumField = "Files"; // historic name for MD5 checksums - else - checksumField.append(*type); - - Files = Section->FindS(checksumField); - if (Files.empty() == false) + Files = Section->Find(hashinfo.chksumskey).to_string(); + if (not Files.empty()) break; } - if (Files.empty() == true) + if (Files.empty()) return false; // Read the first file triplet |
