summaryrefslogtreecommitdiff
path: root/cmdline/apt-helper.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-03-12 20:33:05 +0100
committerMichael Vogt <mvo@debian.org>2014-03-12 20:33:05 +0100
commitc1409d1be88557529c62883be3174793481233de (patch)
tree56abe9525be918676c4f886ee19875054469e1cf /cmdline/apt-helper.cc
parente43a426e5d402d36eb180935fbbf1430a4a86e3f (diff)
add hashsum support in apt-file download and add more tests
Diffstat (limited to 'cmdline/apt-helper.cc')
-rw-r--r--cmdline/apt-helper.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index c1c8b2178..4a24b01d9 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -44,6 +44,9 @@ bool DoDownloadFile(CommandLine &CmdL)
Fetcher.Setup(&Stat);
std::string download_uri = CmdL.FileList[1];
std::string targetfile = CmdL.FileList[2];
+ HashString hash;
+ if (CmdL.FileSize() > 3)
+ hash = HashString(CmdL.FileList[3]);
new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc",
"dest-dir-ignored", targetfile);
Fetcher.Run();
@@ -52,6 +55,14 @@ bool DoDownloadFile(CommandLine &CmdL)
_error->Error(_("Download Failed"));
return false;
}
+ if(hash.empty() == false)
+ if(hash.VerifyFile(targetfile) == false)
+ {
+ _error->Error(_("HashSum Failed"));
+ Rename(targetfile, targetfile+".failed");
+ return false;
+ }
+
return true;
}