X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/1bc849af8f694ab80887bd0e9b94280f78771dbc..bebdca4bf63ae661c60bc1e0f4e03e6bbb7a7cc5:/apt-pkg/acquire-item.cc diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ebef611d8..7e178c3b4 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-item.cc,v 1.23 1999/02/01 08:11:57 jgg Exp $ +// $Id: acquire-item.cc,v 1.27 1999/04/07 05:30:17 jgg Exp $ /* ###################################################################### Acquire Item - Item to acquire @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -32,8 +33,8 @@ // --------------------------------------------------------------------- /* */ pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), FileSize(0), - Mode(0), ID(0), Complete(false), Local(false), - QueueCounter(0) + PartialSize(0), Mode(0), ID(0), Complete(false), + Local(false), QueueCounter(0) { Owner->Add(this); Status = StatIdle; @@ -236,14 +237,6 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5) Mode = "gzip"; } /*}}}*/ -// AcqIndex::Describe - Describe the Item /*{{{*/ -// --------------------------------------------------------------------- -/* */ -string pkgAcqIndex::Describe() -{ - return Location->PackagesURI(); -} - /*}}}*/ // AcqIndexRel::pkgAcqIndexRel - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -322,14 +315,6 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5) Rename(DestFile,FinalFile); } /*}}}*/ -// AcqIndexRel::Describe - Describe the Item /*{{{*/ -// --------------------------------------------------------------------- -/* */ -string pkgAcqIndexRel::Describe() -{ - return Location->ReleaseURI(); -} - /*}}}*/ // AcqIndexRel::Failed - Silence failure messages for missing rel files /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -339,7 +324,9 @@ void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf) if (Cnf->LocalOnly == true || StringToBool(LookupTag(Message,"Transient-Failure"),false) == false) { - Status = StatIdle; + // Ignore this + Status = StatDone; + Complete = false; Dequeue(); return; } @@ -423,8 +410,8 @@ bool pkgAcqArchive::QueueNext() return true; } - /* Hmm, we have a file and its size does not match, this shouldnt - happen.. */ + /* Hmm, we have a file and its size does not match, this means it is + an old style mismatched arch */ unlink(FinalFile.c_str()); } @@ -449,6 +436,16 @@ bool pkgAcqArchive::QueueNext() DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename); + // Check the destination file + if (stat(DestFile.c_str(),&Buf) == 0) + { + // Hmm, the partial file is too big, erase it + if ((unsigned)Buf.st_size > Version->Size) + unlink(DestFile.c_str()); + else + PartialSize = Buf.st_size; + } + // Create the item Desc.URI = Location->ArchiveURI(PkgFile); Desc.Description = Location->ArchiveInfo(Version); @@ -514,14 +511,6 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash) Complete = true; } /*}}}*/ -// AcqArchive::Describe - Describe the Item /*{{{*/ -// --------------------------------------------------------------------- -/* */ -string pkgAcqArchive::Describe() -{ - return Desc.URI; -} - /*}}}*/ // AcqArchive::Failed - Failure handler /*{{{*/ // --------------------------------------------------------------------- /* Here we try other sources */ @@ -541,7 +530,72 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf) return; } + StoreFilename = string(); Item::Failed(Message,Cnf); } } /*}}}*/ + +// 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) +{ + DestFile = flNotDir(URI); + + // Create the item + Desc.URI = URI; + Desc.Description = Dsc; + Desc.Owner = this; + + // Set the short description to the archive component + Desc.ShortDesc = ShortDesc; + + // Get the transfer sizes + FileSize = Size; + struct stat Buf; + if (stat(DestFile.c_str(),&Buf) == 0) + { + // Hmm, the partial file is too big, erase it + if ((unsigned)Buf.st_size > Size) + unlink(DestFile.c_str()); + else + PartialSize = Buf.st_size; + } + + QueueURI(Desc); +} + /*}}}*/ +// AcqFile::Done - Item downloaded OK /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcqFile::Done(string Message,unsigned long Size,string MD5) +{ + Item::Done(Message,Size,MD5); + + string FileName = LookupTag(Message,"Filename"); + if (FileName.empty() == true) + { + Status = StatError; + ErrorText = "Method gave a blank filename"; + return; + } + + Complete = true; + + // The files timestamp matches + if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) + return; + + // We have to copy it into place + if (FileName != DestFile) + { + Local = true; + Desc.URI = "copy:" + FileName; + QueueURI(Desc); + return; + } +} + /*}}}*/