diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:28 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:28 +0000 |
commit | a656821931a863ffcf46a719a57206eb0d2b11b3 (patch) | |
tree | 8db36c9a2e5626d224ea9cbd174978e8edc90b86 /apt-pkg | |
parent | ac2b6b5e14b9f45ef78b1b51ca8fa60a3fca5818 (diff) |
Wow
Author: jgg
Date: 1998-11-13 07:08:48 GMT
Wow
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 56 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 3 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 33 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 8 | ||||
-rw-r--r-- | apt-pkg/algorithms.cc | 4 | ||||
-rw-r--r-- | apt-pkg/depcache.h | 30 |
6 files changed, 102 insertions, 32 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ef5863646..532d4e6f2 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.11 1998/11/13 04:23:26 jgg Exp $ +// $Id: acquire-item.cc,v 1.12 1998/11/13 07:08:48 jgg Exp $ /* ###################################################################### Acquire Item - Item to acquire @@ -32,7 +32,8 @@ // --------------------------------------------------------------------- /* */ pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), FileSize(0), - Mode(0), ID(0), Complete(false), QueueCounter(0) + Mode(0), ID(0), Complete(false), Local(false), + QueueCounter(0) { Owner->Add(this); Status = StatIdle; @@ -192,7 +193,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5) return; Decompression = true; - FileSize = 0; + Local = true; DestFile += ".decomp"; Desc.URI = "copy:" + FileName; QueueURI(Desc); @@ -214,7 +215,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5) if (FileName == DestFile) Erase = true; else - FileSize = 0; + Local = true; Decompression = true; DestFile += ".decomp"; @@ -289,7 +290,7 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5) // We have to copy it into place if (FileName != DestFile) { - FileSize = 0; + Local = true; Desc.URI = "copy:" + FileName; QueueURI(Desc); return; @@ -341,6 +342,29 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, Version.ParentPkg().Name()); return; } + + // See if we already have the file. + FileSize = Version->Size; + string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile); + struct stat Buf; + if (stat(FinalFile.c_str(),&Buf) == 0) + { + // Make sure the size matches + if ((unsigned)Buf.st_size == Version->Size) + { + Complete = true; + Local = true; + Status = StatDone; + DestFile = FinalFile; + return; + } + + /* Hmm, we have a file and its size does not match, this shouldnt + happen.. */ + unlink(FinalFile.c_str()); + } + + DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile); // Create the item Desc.URI = Location->ArchiveURI(PkgFile); @@ -349,7 +373,6 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, Desc.ShortDesc = Version.ParentPkg().Name(); QueueURI(Desc); - DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile); return; } @@ -381,8 +404,8 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash) return; } } - - // Store the destination filename + + // Grab the output filename string FileName = LookupTag(Message,"Filename"); if (FileName.empty() == true) { @@ -390,8 +413,23 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash) ErrorText = "Method gave a blank filename"; return; } + + Complete = true; + + // We have to copy it into place + if (FileName != DestFile) + { + DestFile = FileName; + Local = true; + return; + } + + // Done, move it into position + string FinalFile = _config->FindDir("Dir::Cache::Archives"); + FinalFile += flNotDir(DestFile); + Rename(DestFile,FinalFile); - DestFile = FileName; + DestFile = FinalFile; Complete = true; } /*}}}*/ diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 2de1e409e..67e202355 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-item.h,v 1.8 1998/11/13 04:23:28 jgg Exp $ +// $Id: acquire-item.h,v 1.9 1998/11/13 07:08:50 jgg Exp $ /* ###################################################################### Acquire Item - Item to acquire @@ -45,6 +45,7 @@ class pkgAcquire::Item char *Mode; unsigned long ID; bool Complete; + bool Local; // Number of queues we are inserted into unsigned int QueueCounter; diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 972a466c5..9a546c7e2 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.cc,v 1.14 1998/11/12 04:10:54 jgg Exp $ +// $Id: acquire.cc,v 1.15 1998/11/13 07:08:54 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -344,7 +344,7 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I) return I->NextAcquire; }; /*}}}*/ -// pkgAcquire::Clean - Cleans a directory /*{{{*/ +// Acquire::Clean - Cleans a directory /*{{{*/ // --------------------------------------------------------------------- /* This is a bit simplistic, it looks at every file in the dir and sees if it is part of the download set. */ @@ -398,6 +398,29 @@ pkgAcquire::MethodConfig::MethodConfig() Next = 0; } /*}}}*/ +// Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/ +// --------------------------------------------------------------------- +/* This is the total number of bytes needed */ +unsigned long pkgAcquire::TotalNeeded() +{ + unsigned long Total = 0; + for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++) + Total += (*I)->FileSize; + return Total; +} + /*}}}*/ +// Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/ +// --------------------------------------------------------------------- +/* This is the number of bytes that is not local */ +unsigned long pkgAcquire::FetchNeeded() +{ + unsigned long Total = 0; + for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++) + if ((*I)->Local == false) + Total += (*I)->FileSize; + return Total; +} + /*}}}*/ // Queue::Queue - Constructor /*{{{*/ // --------------------------------------------------------------------- @@ -587,6 +610,10 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner) for (pkgAcquire::Item **I = Owner->ItemsBegin(); I != Owner->ItemsEnd(); I++, Count++) { + // Totally ignore local items + if ((*I)->Local == true) + continue; + TotalBytes += (*I)->FileSize; if ((*I)->Complete == true) CurrentBytes += (*I)->FileSize; @@ -648,7 +675,7 @@ void pkgAcquireStatus::Start() ElapsedTime = 0; } /*}}}*/ -// pkgAcquireStatus::Stop - Finished downloading /*{{{*/ +// AcquireStatus::Stop - Finished downloading /*{{{*/ // --------------------------------------------------------------------- /* This accurately computes the elapsed time and the total overall CPS. */ void pkgAcquireStatus::Stop() diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index c85a7aef7..036a497f4 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.h,v 1.11 1998/11/12 04:10:55 jgg Exp $ +// $Id: acquire.h,v 1.12 1998/11/13 07:08:55 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -101,6 +101,10 @@ class pkgAcquire // Cleans out the download dir bool Clean(string Dir); + + // Returns the size of the total download set + unsigned long TotalNeeded(); + unsigned long FetchNeeded(); pkgAcquire(pkgAcquireStatus *Log = 0); ~pkgAcquire(); @@ -210,7 +214,7 @@ class pkgAcquireStatus virtual void Pulse(pkgAcquire *Owner); virtual void Start(); virtual void Stop(); - + pkgAcquireStatus(); virtual ~pkgAcquireStatus() {}; }; diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 350b57468..a65062a9b 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.8 1998/10/24 04:58:04 jgg Exp $ +// $Id: algorithms.cc,v 1.9 1998/11/13 07:08:57 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -644,7 +644,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { if (Debug == true) clog << " Try to Re-Instate " << I.Name() << endl; - int OldBreaks = Cache.BrokenCount(); + unsigned long OldBreaks = Cache.BrokenCount(); pkgCache::Version *OldVer = Cache[I].InstallVer; Flags[I->ID] &= ReInstateTried; diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index bd64ee5a2..62ab2d8c3 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: depcache.h,v 1.5 1998/10/02 04:39:45 jgg Exp $ +// $Id: depcache.h,v 1.6 1998/11/13 07:08:58 jgg Exp $ /* ###################################################################### DepCache - Dependency Extension data for the cache @@ -118,13 +118,13 @@ class pkgDepCache : public pkgCache StateCache *PkgState; unsigned char *DepState; - long iUsrSize; - long iDownloadSize; - long iInstCount; - long iDelCount; - long iKeepCount; - long iBrokenCount; - long iBadCount; + signed long iUsrSize; + unsigned long iDownloadSize; + unsigned long iInstCount; + unsigned long iDelCount; + unsigned long iKeepCount; + unsigned long iBrokenCount; + unsigned long iBadCount; // Check for a matching provides bool CheckDep(DepIterator Dep,int Type,PkgIterator &Res); @@ -169,13 +169,13 @@ class pkgDepCache : public pkgCache void Update(OpProgress *Prog = 0); // Size queries - inline long UsrSize() {return iUsrSize;}; - inline long DebSize() {return iDownloadSize;}; - inline long DelCount() {return iDelCount;}; - inline long KeepCount() {return iKeepCount;}; - inline long InstCount() {return iInstCount;}; - inline long BrokenCount() {return iBrokenCount;}; - inline long BadCount() {return iBadCount;}; + inline signed long UsrSize() {return iUsrSize;}; + inline unsigned long DebSize() {return iDownloadSize;}; + inline unsigned long DelCount() {return iDelCount;}; + inline unsigned long KeepCount() {return iKeepCount;}; + inline unsigned long InstCount() {return iInstCount;}; + inline unsigned long BrokenCount() {return iBrokenCount;}; + inline unsigned long BadCount() {return iBadCount;}; pkgDepCache(MMap &Map,OpProgress &Prog); virtual ~pkgDepCache(); |