]> git.saurik.com Git - apt.git/commitdiff
load the size from the metaindex into the fetcher to have even more accurate progress...
authorMichael Vogt <mvo@ubuntu.com>
Wed, 16 Apr 2014 13:28:23 +0000 (15:28 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Wed, 16 Apr 2014 13:28:23 +0000 (15:28 +0200)
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/acquire.cc
apt-pkg/indexrecords.cc
apt-pkg/indexrecords.h

index 6f6b3d59f276a5a90d19e171c356fa7165b6c680..d5f8b0cc975fb58c9cb1d0a24000de92af8beed6 100644 (file)
@@ -936,7 +936,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
    Init(URI, URIDesc, ShortDesc);
 }
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
-                        HashString const &ExpectedHash, indexRecords const *MetaIndexParser)
+                        HashString const &ExpectedHash, indexRecords *MetaIndexParser)
    : Item(Owner), RealURI(Target->URI), ExpectedHash(ExpectedHash)
 {
    // autoselect the compression method
@@ -963,6 +963,11 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
    else
      Verify = true;
 
+   // load the filesize
+   indexRecords::checkSum *Record = MetaIndexParser->Lookup(string(Target->MetaKey));
+   if(Record)
+      FileSize = Record->Size;
+   
    Init(Target->URI, Target->Description, Target->ShortDesc);
 }
                                                                        /*}}}*/
@@ -1176,9 +1181,13 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
 {
 }
 pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const *Target,
-                        HashString const &ExpectedHash, indexRecords const *MetaIndexParser)
+                        HashString const &ExpectedHash, indexRecords *MetaIndexParser)
   : pkgAcqIndex(Owner, Target, ExpectedHash, MetaIndexParser)
 {
+   // load the filesize
+   indexRecords::checkSum *Record = MetaIndexParser->Lookup(string(Target->MetaKey));
+   if(Record)
+      FileSize = Record->Size;
 }
                                                                        /*}}}*/
 // AcqIndexTrans::Custom600Headers - Insert custom request headers     /*{{{*/
@@ -1575,7 +1584,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)                           /*{{{*/
         ++Target)
    {
       HashString ExpectedIndexHash;
-      const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+      indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
       bool compressedAvailable = false;
       if (Record == NULL)
       {
index c12d8d63aedc9f98ea30a2b63204ea3ccf975b90..bf5cb09c81c2715d2dd5a07eb346060a6585f391 100644 (file)
@@ -756,7 +756,7 @@ class pkgAcqIndex : public pkgAcquire::Item
               std::string ShortDesc, HashString ExpectedHash, 
               std::string compressExt="");
    pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
-                        HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
+                        HashString const &ExpectedHash, indexRecords *MetaIndexParser);
    void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
 };
                                                                        /*}}}*/
@@ -788,7 +788,7 @@ class pkgAcqIndexTrans : public pkgAcqIndex
    pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
                    std::string ShortDesc);
    pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
-                   HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
+                   HashString const &ExpectedHash, indexRecords *MetaIndexParser);
 };
                                                                        /*}}}*/
 /** \brief Information about an index file. */                         /*{{{*/
index 2b427ccd347f10da9f8fc7a0c9694097a669ed16..9fc40752fab4d9c9930e5474bceb703444f9bbe0 100644 (file)
@@ -905,8 +905,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
         
 
       // calculate the percentage, if we have too little data assume 0%
+      // FIXME: the 5k is totally arbitrary 
+      // FIXME2: instead, use a algorithm where 50% is based on total bytes
+      //         and the other 50% on total files
       int Percent;
-      if (TotalBytes < 1*1024)
+      if (TotalBytes < 5*1024)
          Percent = 0;
       else
          Percent = (CurrentBytes/float(TotalBytes)*100.0);
index 5353d109845cd6fe7ebf7584b6a56c3ee0c62906..68ebdce0886fb5065a3cec1e5297b49cbf160107 100644 (file)
@@ -53,7 +53,7 @@ APT_PURE time_t indexRecords::GetValidUntil() const
    return this->ValidUntil;
 }
 
-APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
+APT_PURE indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
 {
    std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
    if (sum == Entries.end())
index e31f889ad17ea384d8bf69e5322323def33d22f6..2260a4ae1edb2202480cb46a58362bbf4adff007 100644 (file)
@@ -41,7 +41,7 @@ class indexRecords
    indexRecords(const std::string ExpectedDist);
 
    // Lookup function
-   virtual const checkSum *Lookup(const std::string MetaKey);
+   virtual checkSum *Lookup(const std::string MetaKey);
    /** \brief tests if a checksum for this file is available */
    bool Exists(std::string const &MetaKey) const;
    std::vector<std::string> MetaKeys();