From cb6a2b3eaca4353d7f490fb360b98c08d64a2d8c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 14 Jan 2013 07:09:51 +0100 Subject: first iteration that adds support for checksums-{sha512,sha256} --- cmdline/apt-get.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1bb981b20..68e7f829c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2555,15 +2555,12 @@ bool DoSource(CommandLine &CmdL) if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end()) continue; queued.insert(Last->Index().ArchiveURI(I->Path)); - + // check if we have a file with that md5 sum already localy - if(!I->MD5Hash.empty() && FileExists(flNotDir(I->Path))) + if(!I->Hash.empty() && FileExists(flNotDir(I->Path))) { - FileFd Fd(flNotDir(I->Path), FileFd::ReadOnly); - MD5Summation sum; - sum.AddFD(Fd.Fd(), Fd.Size()); - Fd.Close(); - if((string)sum.Result() == I->MD5Hash) + HashString hash_string = HashString(I->Hash); + if(hash_string.VerifyFile(I->Path)) { ioprintf(c1out,_("Skipping already downloaded file '%s'\n"), flNotDir(I->Path).c_str()); @@ -2572,7 +2569,7 @@ bool DoSource(CommandLine &CmdL) } new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path), - I->MD5Hash,I->Size, + I->Hash,I->Size, Last->Index().SourceInfo(*Last,*I),Src); } } -- cgit v1.2.3-70-g09d2 From 64680d3bf12db6599e93f950546e380e0bd5ddf4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 14 Jan 2013 07:59:52 +0100 Subject: fix skipping of already downloaded files and add some FIXMEs --- apt-pkg/deb/debsrcrecords.cc | 13 +++++++++---- cmdline/apt-get.cc | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'cmdline') diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 45cc0ae82..c620c2298 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -116,16 +116,21 @@ bool debSrcRecordParser::Files(std::vector &List) { List.erase(List.begin(),List.end()); + // FIXME: build string dynamically from + // Hashes::SupportedHashes const char *hash_field[] = { "Checksums-Sha512", "Checksums-Sha256", "Checksums-Sha1", "Files", // historic name NULL, }; - const char *hash_type[] = { "Sha512", - "Sha256", - "Sha1", - "md5sum", + + // FIXME: use string from Hashes::SupportedHashes + // FIXME2: this is case senstivie + const char *hash_type[] = { "SHA512", + "SHA256", + "SHA1", + "MD5Sum", NULL, }; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 68e7f829c..a2a19cd11 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2560,7 +2560,7 @@ bool DoSource(CommandLine &CmdL) if(!I->Hash.empty() && FileExists(flNotDir(I->Path))) { HashString hash_string = HashString(I->Hash); - if(hash_string.VerifyFile(I->Path)) + if(hash_string.VerifyFile(flNotDir(I->Path))) { ioprintf(c1out,_("Skipping already downloaded file '%s'\n"), flNotDir(I->Path).c_str()); -- cgit v1.2.3-70-g09d2