*/
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
string URI,string URIDesc,string ShortDesc,
- HashString ExpectedMD5,
+ HashString ExpectedHash,
vector<DiffInfo> diffs)
: Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash),
available_patches(diffs)
std::cerr << " Expected Hash: " << ExpectedHash.toStr() << std::endl;
}
- if (!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile))
+ if (!ExpectedHash.empty() && ExpectedHash.toStr() != Hash)
{
Status = StatAuthError;
ErrorText = _("Hash Sum mismatch");
// The files timestamp matches
if (StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
return;
-
Decompression = true;
Local = true;
DestFile += ".decomp";
// The files timestamp matches
if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+ {
+ unlink(FileName.c_str());
return;
+ }
if (FileName == DestFile)
Erase = true;
Local = true;
string compExt = Desc.URI.substr(Desc.URI.size()-3);
- char *decompProg;
+ const char *decompProg;
if(compExt == "bz2")
decompProg = "bzip2";
else if(compExt == ".gz")
// see if the download was a IMSHit
IMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false);
-
Complete = true;
string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile += URItoFileName(RealURI);
- // The files timestamp matches
- if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == false)
- {
- // Move it into position
+ // If we get a IMS hit we can remove the empty file in partial
+ // othersie we move the file in place
+ if (IMSHit)
+ unlink(DestFile.c_str());
+ else
Rename(DestFile,FinalFile);
- }
+
chmod(FinalFile.c_str(),0644);
DestFile = FinalFile;
}
string PkgFile = Parse.FileName();
if(Parse.SHA256Hash() != "")
- hash = HashString("SHA256", Parse.SHA256Hash());
+ ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
else if (Parse.SHA1Hash() != "")
- hash = HashString("SHA1", Parse.SHA1Hash());
+ ExpectedHash = HashString("SHA1", Parse.SHA1Hash());
else
- hash = HashString("MD5Sum", Parse.MD5Hash());
+ ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
if (PkgFile.empty() == true)
return _error->Error(_("The package index files are corrupted. No Filename: "
"field for package %s."),
}
// Check the hash
- if(!hash.VerifyFile(DestFile))
+ if(ExpectedHash.toStr() != CalcHash)
{
Status = StatError;
ErrorText = _("Hash Sum mismatch");
// AcqFile::pkgAcqFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The file is added to the queue */
-pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
+pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
unsigned long Size,string Dsc,string ShortDesc,
const string &DestDir, const string &DestFilename) :
- Item(Owner), hash(MD5)
+ Item(Owner), ExpectedHash(Hash)
{
Retries = _config->FindI("Acquire::Retries",0);
{
Item::Done(Message,Size,CalcHash,Cnf);
- // Check the md5
- if(!hash.VerifyFile(DestFile))
+ // Check the hash
+ if(!ExpectedHash.empty() && ExpectedHash.toStr() != CalcHash)
{
Status = StatError;
ErrorText = "Hash Sum mismatch";