// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.cc,v 1.28 1999/04/20 05:59:29 jgg Exp $
+// $Id: acquire-item.cc,v 1.40 1999/10/31 06:32:27 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
// ---------------------------------------------------------------------
/* Stash status and the file size. Note that setting Complete means
sub-phases of the acquire process such as decompresion are operating */
-void pkgAcquire::Item::Start(string Message,unsigned long Size)
+void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size)
{
Status = StatFetching;
if (FileSize == 0 && Complete == false)
if (Owner->Log != 0)
Owner->Log->Fetched(Size,atoi(LookupTag(Message,"Resume-Point","0").c_str()));
}
+
+ if (FileSize == 0)
+ FileSize= Size;
Status = StatDone;
ErrorText = string();
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(Location->PackagesURI());
- // Create the item
+ // Create the item
Desc.URI = Location->PackagesURI() + ".gz";
Desc.Description = Location->PackagesInfo();
Desc.Owner = this;
/* */
void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
{
- // This is the retry counter
if (Cnf->LocalOnly == true ||
StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
{
StoreFilename(StoreFilename), Vf(Version.FileList())
{
Retries = _config->FindI("Acquire::Retries",0);
-
+
+ if (Version.Arch() == 0)
+ {
+ _error->Error("I wasn't able to locate file for the %s package. "
+ "This might mean you need to manually fix this package. (due to missing arch)",
+ Version.ParentPkg().Name());
+ return;
+ }
+
// Generate the final file name as: package_version_arch.deb
StoreFilename = QuoteString(Version.ParentPkg().Name(),"_:") + '_' +
QuoteString(Version.VerStr(),"_:") + '_' +
QuoteString(Version.Arch(),"_:.") + ".deb";
-
+
// Select a source
if (QueueNext() == false && _error->PendingError() == false)
_error->Error("I wasn't able to locate file for the %s package. "
// Check the size
if (Size != Version->Size)
{
- _error->Error("Size mismatch for package %s",Version.ParentPkg().Name());
+ Status = StatError;
+ ErrorText = "Size mismatch";
return;
}
{
if (Md5Hash != MD5)
{
- _error->Error("MD5Sum mismatch for package %s",Version.ParentPkg().Name());
- Rename(DestFile + ".FAILED",DestFile);
+ Status = StatError;
+ ErrorText = "MD5Sum mismatch";
+ Rename(DestFile,DestFile + ".FAILED");
return;
}
}
}
}
/*}}}*/
+// AcqArchive::Finished - Fetching has finished, tidy up /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqArchive::Finished()
+{
+ if (Status == pkgAcquire::Item::StatDone &&
+ Complete == true)
+ return;
+ StoreFilename = string();
+}
+ /*}}}*/
// AcqFile::pkgAcqFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The file is added to the queue */
pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
unsigned long Size,string Dsc,string ShortDesc) :
- Item(Owner), MD5(MD5)
+ Item(Owner), Md5Hash(MD5)
{
+ Retries = _config->FindI("Acquire::Retries",0);
+
DestFile = flNotDir(URI);
// Create the item
/* */
void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
{
+ // Check the md5
+ if (Md5Hash.empty() == false && MD5.empty() == false)
+ {
+ if (Md5Hash != MD5)
+ {
+ Status = StatError;
+ ErrorText = "MD5Sum mismatch";
+ Rename(DestFile,DestFile + ".FAILED");
+ return;
+ }
+ }
+
Item::Done(Message,Size,MD5);
string FileName = LookupTag(Message,"Filename");
if (FileName != DestFile)
{
Local = true;
- Desc.URI = "copy:" + FileName;
+ if (_config->FindB("Acquire::Source-Symlinks",true) == false)
+ {
+ Desc.URI = "copy:" + FileName;
+ QueueURI(Desc);
+ return;
+ }
+
+ // Erase the file if it is a symlink so we can overwrite it
+ struct stat St;
+ if (lstat(DestFile.c_str(),&St) == 0)
+ {
+ if (S_ISLNK(St.st_mode) != 0)
+ unlink(DestFile.c_str());
+ }
+
+ // Symlink the file
+ if (symlink(FileName.c_str(),DestFile.c_str()) != 0)
+ {
+ ErrorText = "Link to " + DestFile + " failure ";
+ Status = StatError;
+ Complete = false;
+ }
+ }
+}
+ /*}}}*/
+// AcqFile::Failed - Failure handler /*{{{*/
+// ---------------------------------------------------------------------
+/* Here we try other sources */
+void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+{
+ ErrorText = LookupTag(Message,"Message");
+
+ // This is the retry counter
+ if (Retries != 0 &&
+ Cnf->LocalOnly == false &&
+ StringToBool(LookupTag(Message,"Transient-Failure"),false) == true)
+ {
+ Retries--;
QueueURI(Desc);
return;
}
+
+ Item::Failed(Message,Cnf);
}
/*}}}*/