]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
let the Mark methods return if their marking was successful
[apt.git] / apt-pkg / deb / debindexfile.cc
index a89a2574f282a172373ac0a5726abe035a671cf2..1e8c040333b028def25e8330b484ab4cb15ac035 100644 (file)
@@ -66,7 +66,10 @@ pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
    string SourcesURI = _config->FindDir("Dir::State::lists") + 
       URItoFileName(IndexURI("Sources"));
    string SourcesURIgzip = SourcesURI + ".gz";
-   if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
+
+   if (!FileExists(SourcesURI) && !FileExists(SourcesURIgzip))
+      return NULL;
+   else if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
       SourcesURI = SourcesURIgzip;
 
    return new debSrcRecordParser(SourcesURI,this);
@@ -149,11 +152,20 @@ bool debSourcesIndex::Exists() const
 /* */
 unsigned long debSourcesIndex::Size() const
 {
+   unsigned long size = 0;
+
+   /* we need to ignore errors here; if the lists are absent, just return 0 */
+   _error->PushToStack();
+
    FileFd f = FileFd (IndexFile("Sources"), FileFd::ReadOnlyGzip);
+   if (!f.Failed())
+      size = f.Size();
 
-   if (f.Failed())
-      return 0;
-   return f.Size();
+   if (_error->PendingError() == true)
+       size = 0;
+   _error->RevertToStack();
+
+   return size;
 }
                                                                        /*}}}*/
 
@@ -269,11 +281,20 @@ bool debPackagesIndex::Exists() const
 /* This is really only used for progress reporting. */
 unsigned long debPackagesIndex::Size() const
 {
+   unsigned long size = 0;
+
+   /* we need to ignore errors here; if the lists are absent, just return 0 */
+   _error->PushToStack();
+
    FileFd f = FileFd (IndexFile("Packages"), FileFd::ReadOnlyGzip);
+   if (!f.Failed())
+      size = f.Size();
 
-   if (f.Failed())
-      return 0;
-   return f.Size();
+   if (_error->PendingError() == true)
+       size = 0;
+   _error->RevertToStack();
+
+   return size;
 }
                                                                        /*}}}*/
 // PackagesIndex::Merge - Load the index file into a cache             /*{{{*/
@@ -306,8 +327,14 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
       return _error->Error("Problem with MergeList %s",PackageFile.c_str());
 
    // Check the release file
-   string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
+   string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("InRelease");
+   bool releaseExists = false;
    if (FileExists(ReleaseFile) == true)
+      releaseExists = true;
+   else
+      ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
+
+   if (releaseExists == true || FileExists(ReleaseFile) == true)
    {
       FileFd Rel(ReleaseFile,FileFd::ReadOnly);
       if (_error->PendingError() == true)
@@ -460,12 +487,20 @@ bool debTranslationsIndex::Exists() const
 /* This is really only used for progress reporting. */
 unsigned long debTranslationsIndex::Size() const
 {
+   unsigned long size = 0;
+
+   /* we need to ignore errors here; if the lists are absent, just return 0 */
+   _error->PushToStack();
+
    FileFd f = FileFd (IndexFile(Language), FileFd::ReadOnlyGzip);
+   if (!f.Failed())
+      size = f.Size();
 
-   if (f.Failed())
-      return 0;
+   if (_error->PendingError() == true)
+       size = 0;
+   _error->RevertToStack();
 
-   return f.Size();
+   return size;
 }
                                                                        /*}}}*/
 // TranslationsIndex::Merge - Load the index file into a cache         /*{{{*/