]> git.saurik.com Git - apt.git/commitdiff
Add FindInCache method to skip the rebuild of cache every time.
authorOtavio Salvador <otavio@debian.org>
Fri, 13 May 2005 14:05:10 +0000 (14:05 +0000)
committerOtavio Salvador <otavio@debian.org>
Fri, 13 May 2005 14:05:10 +0000 (14:05 +0000)
apt-pkg/deb/debindexfile.cc
apt-pkg/deb/debindexfile.h

index 4113137eb921c6da4f4d13dcb2bff51df3a184fe..b8435a6bc29e055928d45a98f3f3060c28bd4c39 100644 (file)
@@ -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                           /*{{{*/
 // ---------------------------------------------------------------------
 /* */
index 7bd7ea4f36ae178802f73be21db0f717802f9a18..6d423318e7296a3fdd5477b624c1cb295829f3ec 100644 (file)
@@ -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);
 };