apt-pkg/deb/debindexfile.cc: Fix one more place to check for gzipped indexes, to...
[ntk/apt.git] / apt-pkg / deb / debindexfile.cc
index 5beb836..9832329 100644 (file)
@@ -35,12 +35,12 @@ debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trus
 // SourcesIndex::SourceInfo - Short 1 liner describing a source                /*{{{*/
 // ---------------------------------------------------------------------
 /* The result looks like:
-     http://foo/ stable/main src 1.1.1 (dsc) */
+     http://foo/debian/ stable/main src 1.1.1 (dsc) */
 string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
                                   pkgSrcRecords::File const &File) const
 {
    string Res;
-   Res = ::URI::SiteOnly(URI) + ' ';
+   Res = ::URI::NoUserPassword(URI) + ' ';
    if (Dist[Dist.size() - 1] == '/')
    {
       if (Dist != "/")
@@ -63,9 +63,13 @@ string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
 /* */
 pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
 {
-   string SourcesURI = URItoFileName(IndexURI("Sources"));
-   return new debSrcRecordParser(_config->FindDir("Dir::State::lists") +
-                                SourcesURI,this);
+   string SourcesURI = _config->FindDir("Dir::State::lists") + 
+      URItoFileName(IndexURI("Sources"));
+   string SourcesURIgzip = SourcesURI + ".gz";
+   if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
+      SourcesURI = SourcesURIgzip;
+
+   return new debSrcRecordParser(SourcesURI,this);
 }
                                                                        /*}}}*/
 // SourcesIndex::Describe - Give a descriptive path to the index       /*{{{*/
@@ -88,7 +92,7 @@ string debSourcesIndex::Describe(bool Short) const
 /* */
 string debSourcesIndex::Info(const char *Type) const
 {
-   string Info = ::URI::SiteOnly(URI) + ' ';
+   string Info = ::URI::NoUserPassword(URI) + ' ';
    if (Dist[Dist.size() - 1] == '/')
    {
       if (Dist != "/")
@@ -106,8 +110,14 @@ string debSourcesIndex::Info(const char *Type) const
 /* */
 inline string debSourcesIndex::IndexFile(const char *Type) const
 {
-   return URItoFileName(IndexURI(Type));
+   string s = URItoFileName(IndexURI(Type));
+   string sgzip = s + ".gz";
+   if (!FileExists(s) && FileExists(sgzip))
+       return sgzip;
+   else
+       return s;
 }
+
 string debSourcesIndex::IndexURI(const char *Type) const
 {
    string Res;
@@ -159,7 +169,7 @@ debPackagesIndex::debPackagesIndex(string URI,string Dist,string Section,bool Tr
 /* This is a shorter version that is designed to be < 60 chars or so */
 string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
 {
-   string Res = ::URI::SiteOnly(URI) + ' ';
+   string Res = ::URI::NoUserPassword(URI) + ' ';
    if (Dist[Dist.size() - 1] == '/')
    {
       if (Dist != "/")
@@ -195,7 +205,7 @@ string debPackagesIndex::Describe(bool Short) const
 /* */
 string debPackagesIndex::Info(const char *Type) const 
 {
-   string Info = ::URI::SiteOnly(URI) + ' ';
+   string Info = ::URI::NoUserPassword(URI) + ' ';
    if (Dist[Dist.size() - 1] == '/')
    {
       if (Dist != "/")
@@ -213,7 +223,12 @@ string debPackagesIndex::Info(const char *Type) const
 /* */
 inline string debPackagesIndex::IndexFile(const char *Type) const
 {
-   return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+   string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+   string sgzip = s + ".gz";
+   if (!FileExists(s) && FileExists(sgzip))
+       return sgzip;
+   else
+       return s;
 }
 string debPackagesIndex::IndexURI(const char *Type) const
 {
@@ -306,9 +321,19 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "PackagesIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "PackagesIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }
    
@@ -330,7 +355,12 @@ debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section
 /* */
 inline string debTranslationsIndex::IndexFile(const char *Type) const
 {
-   return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+   string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+   string sgzip = s + ".gz";
+   if (!FileExists(s) && FileExists(sgzip))
+       return sgzip;
+   else
+       return s;
 }
 string debTranslationsIndex::IndexURI(const char *Type) const
 {
@@ -385,7 +415,7 @@ string debTranslationsIndex::Describe(bool Short) const
 /* */
 string debTranslationsIndex::Info(const char *Type) const 
 {
-   string Info = ::URI::SiteOnly(URI) + ' ';
+   string Info = ::URI::NoUserPassword(URI) + ' ';
    if (Dist[Dist.size() - 1] == '/')
    {
       if (Dist != "/")
@@ -473,9 +503,19 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con
 
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "TranslationIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "TranslationIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }   
    return File;
@@ -542,9 +582,19 @@ pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const
       
       struct stat St;
       if (stat(File.FileName(),&St) != 0)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "StatusIndex::FindInCache - stat failed on " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+      {
+         if (_config->FindB("Debug::pkgCacheGen", false))
+           std::clog << "StatusIndex::FindInCache - size (" << St.st_size << " <> " << File->Size
+                       << ") or mtime (" << St.st_mtime << " <> " << File->mtime
+                       << ") doesn't match for " << File.FileName() << std::endl;
         return pkgCache::PkgFileIterator(Cache);
+      }
       return File;
    }   
    return File;