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

Add FindInCache method to skip the rebuild of cache every time.

Otavio Salvador лет назад: 21
Родитель
Сommit
c51c6f08ab
2 измененных файлов с 23 добавлено и 1 удалено
  1. 22 1
      apt-pkg/deb/debindexfile.cc
  2. 1 0
      apt-pkg/deb/debindexfile.h

+ 22 - 1
apt-pkg/deb/debindexfile.cc

@@ -453,7 +453,28 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
    return true;
 }
 									/*}}}*/
-
+// TranslationsIndex::FindInCache - Find this index				/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
+{
+   pkgCache::PkgFileIterator File = Cache.FileBegin();
+   if (this->UseTranslation()) 
+     for (; File.end() == false; File++)
+       {
+	 if (IndexFile(LanguageCode().c_str()) != File.FileName())
+	   continue;
+      
+	 struct stat St;
+	 if (stat(File.FileName(),&St) != 0)
+	   return pkgCache::PkgFileIterator(Cache);
+	 if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+	   return pkgCache::PkgFileIterator(Cache);
+	 return File;
+       }   
+   return File;
+}
+									/*}}}*/
 // StatusIndex::debStatusIndex - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 1 - 0
apt-pkg/deb/debindexfile.h

@@ -99,6 +99,7 @@ class debTranslationsIndex : public pkgIndexFile
    virtual bool HasPackages() const {return true;};
    virtual unsigned long Size() const;
    virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
+   virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
    debTranslationsIndex(string URI,string Dist,string Section);
 };