summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2022-04-01 11:37:26 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2022-04-01 14:16:19 +0200
commit05fae6fae95d8ef6690f3d56863e3bb6a44d424c (patch)
treec948709ce9b2e4f4bc6e11138c3c21671d3baf37 /ftparchive
parent472376be6818b5ea43250abcbecfcab53b4a729a (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 'ftparchive')
-rw-r--r--ftparchive/writer.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index c786be6ac..ae427b120 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -771,21 +771,21 @@ bool SourcesWriter::DoPackage(string FileName)
{
if (hs->HashType() == "MD5Sum" || hs->HashType() == "Checksum-FileSize")
continue;
- char const * fieldname;
+ pkgTagSection::Key fieldkey;
std::string * out;
if (hs->HashType() == "SHA1")
{
- fieldname = "Checksums-Sha1";
+ fieldkey = pkgTagSection::Key::Checksums_Sha1;
out = &ChecksumsSha1;
}
else if (hs->HashType() == "SHA256")
{
- fieldname = "Checksums-Sha256";
+ fieldkey = pkgTagSection::Key::Checksums_Sha256;
out = &ChecksumsSha256;
}
else if (hs->HashType() == "SHA512")
{
- fieldname = "Checksums-Sha512";
+ fieldkey = pkgTagSection::Key::Checksums_Sha512;
out = &ChecksumsSha512;
}
else
@@ -793,7 +793,7 @@ bool SourcesWriter::DoPackage(string FileName)
_error->Warning("Ignoring unknown Checksumtype %s in SourcesWriter::DoPackages", hs->HashType().c_str());
continue;
}
- if (Tags.Exists(fieldname) == true)
+ if (Tags.Exists(fieldkey))
continue;
std::ostringstream streamout;
streamout << "\n " << hs->HashValue() << " " << std::to_string(Db.GetFileSize()) << " " << ParseJnk;