diff options
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r-- | apt-pkg/acquire-item.cc | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index e1049dde9..e6eee197b 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.3 1998/10/22 04:56:38 jgg Exp $ +// $Id: acquire-item.cc,v 1.4 1998/10/24 04:57:56 jgg Exp $ /* ###################################################################### Acquire Item - Item to acquire @@ -22,6 +22,9 @@ #include <sys/stat.h> #include <unistd.h> +#include <errno.h> +#include <string.h> +#include <stdio.h> /*}}}*/ // Acquire::Item::Item - Constructor /*{{{*/ @@ -30,6 +33,7 @@ pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), QueueCounter(0) { Owner->Add(this); + Status = StatIdle; } /*}}}*/ // Acquire::Item::~Item - Destructor /*{{{*/ @@ -40,6 +44,27 @@ pkgAcquire::Item::~Item() Owner->Remove(this); } /*}}}*/ +// Acquire::Item::Failed - Item failed to download /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcquire::Item::Failed(string Message) +{ + Status = StatError; + ErrorText = LookupTag(Message,"Message"); + if (QueueCounter <= 1) + Owner->Dequeue(this); +} + /*}}}*/ +// Acquire::Item::Done - Item downloaded OK /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgAcquire::Item::Done(string,unsigned long,string) +{ + Status = StatDone; + ErrorText = string(); + Owner->Dequeue(this); +} + /*}}}*/ // AcqIndex::AcqIndex - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -100,3 +125,40 @@ string pkgAcqIndexRel::Custom600Headers() return "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); } /*}}}*/ +// AcqIndexRel::Done - Item downloaded OK /*{{{*/ +// --------------------------------------------------------------------- +/* The release file was not placed into the download directory then + a copy URI is generated and it is copied there otherwise the file + in the partial directory is moved into .. and the URI is finished. */ +void pkgAcqIndexRel::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"; + } + + // We have to copy it into place + if (FileName != DestFile) + { + QueueURI("copy:" + FileName,string()); + return; + } + + // Done, move it into position + string FinalFile = _config->FindDir("Dir::State::lists"); + FinalFile += URItoFileName(Location->ReleaseURI()); + + if (rename(DestFile.c_str(),FinalFile.c_str()) != 0) + { + char S[300]; + sprintf(S,"rename failed, %s (%s -> %s).",strerror(errno), + DestFile.c_str(),FinalFile.c_str()); + Status = StatError; + ErrorText = S; + } +} + /*}}}*/ |