Просмотр исходного кода

load the size from the metaindex into the fetcher to have even more accurate progress information

Michael Vogt лет назад: 12
Родитель
Сommit
1dca8dc55c
5 измененных файлов с 20 добавлено и 8 удалено
  1. 12 3
      apt-pkg/acquire-item.cc
  2. 2 2
      apt-pkg/acquire-item.h
  3. 4 1
      apt-pkg/acquire.cc
  4. 1 1
      apt-pkg/indexrecords.cc
  5. 1 1
      apt-pkg/indexrecords.h

+ 12 - 3
apt-pkg/acquire-item.cc

@@ -936,7 +936,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
    Init(URI, URIDesc, ShortDesc);
    Init(URI, URIDesc, ShortDesc);
 }
 }
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
 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)
    : Item(Owner), RealURI(Target->URI), ExpectedHash(ExpectedHash)
 {
 {
    // autoselect the compression method
    // autoselect the compression method
@@ -963,6 +963,11 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
    else
    else
      Verify = true;
      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);
    Init(Target->URI, Target->Description, Target->ShortDesc);
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -1176,9 +1181,13 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
 {
 {
 }
 }
 pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const *Target,
 pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const *Target,
-			 HashString const &ExpectedHash, indexRecords const *MetaIndexParser)
+			 HashString const &ExpectedHash, indexRecords *MetaIndexParser)
   : pkgAcqIndex(Owner, Target, ExpectedHash, 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	/*{{{*/
 // AcqIndexTrans::Custom600Headers - Insert custom request headers	/*{{{*/
@@ -1575,7 +1584,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
         ++Target)
         ++Target)
    {
    {
       HashString ExpectedIndexHash;
       HashString ExpectedIndexHash;
-      const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+      indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
       bool compressedAvailable = false;
       bool compressedAvailable = false;
       if (Record == NULL)
       if (Record == NULL)
       {
       {

+ 2 - 2
apt-pkg/acquire-item.h

@@ -756,7 +756,7 @@ class pkgAcqIndex : public pkgAcquire::Item
 	       std::string ShortDesc, HashString ExpectedHash, 
 	       std::string ShortDesc, HashString ExpectedHash, 
 	       std::string compressExt="");
 	       std::string compressExt="");
    pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
    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);
    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,
    pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
 		    std::string ShortDesc);
 		    std::string ShortDesc);
    pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
    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. */				/*{{{*/
 /** \brief Information about an index file. */				/*{{{*/

+ 4 - 1
apt-pkg/acquire.cc

@@ -905,8 +905,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
 	 
 	 
 
 
       // calculate the percentage, if we have too little data assume 0%
       // 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;
       int Percent;
-      if (TotalBytes < 1*1024)
+      if (TotalBytes < 5*1024)
          Percent = 0;
          Percent = 0;
       else
       else
          Percent = (CurrentBytes/float(TotalBytes)*100.0);
          Percent = (CurrentBytes/float(TotalBytes)*100.0);

+ 1 - 1
apt-pkg/indexrecords.cc

@@ -53,7 +53,7 @@ APT_PURE time_t indexRecords::GetValidUntil() const
    return this->ValidUntil;
    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);
    std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
    if (sum == Entries.end())
    if (sum == Entries.end())

+ 1 - 1
apt-pkg/indexrecords.h

@@ -41,7 +41,7 @@ class indexRecords
    indexRecords(const std::string ExpectedDist);
    indexRecords(const std::string ExpectedDist);
 
 
    // Lookup function
    // 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 */
    /** \brief tests if a checksum for this file is available */
    bool Exists(std::string const &MetaKey) const;
    bool Exists(std::string const &MetaKey) const;
    std::vector<std::string> MetaKeys();
    std::vector<std::string> MetaKeys();