Sync
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:50:58 +0000 (16:50 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:50:58 +0000 (16:50 +0000)
Author: jgg
Date: 1998-09-18 02:42:38 GMT
Sync

apt-pkg/contrib/error.cc
apt-pkg/contrib/error.h
apt-pkg/pkgcachegen.cc

index 42e01e9..bbd081d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: error.cc,v 1.4 1998/09/12 02:46:26 jgg Exp $
+// $Id: error.cc,v 1.5 1998/09/18 02:42:40 jgg Exp $
 /* ######################################################################
    
    Global Erorr Class - Global error mechanism
@@ -91,6 +91,32 @@ bool GlobalError::Errno(const char *Function,const char *Description,...)
    
    PendingFlag = true;
 
+   return false;   
+}
+                                                                       /*}}}*/
+// GlobalError::WarningE - Get part of the warn string from errno      /*{{{*/
+// ---------------------------------------------------------------------
+/* Function indicates the stdlib function that failed and Description is
+   a user string that leads the text. Form is:
+     Description - Function (errno: strerror)
+   Carefull of the buffer overrun, sprintf.
+ */
+bool GlobalError::WarningE(const char *Function,const char *Description,...)
+{
+   va_list args;
+   va_start(args,Description);
+
+   // sprintf the description
+   char S[400];
+   vsprintf(S,Description,args);
+   sprintf(S + strlen(S)," - %s (%i %s)",Function,errno,strerror(errno));
+
+   // Put it on the list
+   Item *Itm = new Item;
+   Itm->Text = S;
+   Itm->Error = false;
+   Insert(Itm);
+   
    return false;   
 }
                                                                        /*}}}*/
index 7250bb1..9b54b72 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: error.h,v 1.4 1998/09/12 02:46:27 jgg Exp $
+// $Id: error.h,v 1.5 1998/09/18 02:42:41 jgg Exp $
 /* ######################################################################
    
    Global Erorr Class - Global error mechanism
@@ -64,6 +64,7 @@ class GlobalError
 
    // Call to generate an error from a library call.
    bool Errno(const char *Function,const char *Description,...);
+   bool WarningE(const char *Function,const char *Description,...);
 
    /* A warning should be considered less severe than an error, and may be
       ignored by the client. */
index 825af40..46ae33c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.cc,v 1.15 1998/09/07 05:28:37 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.16 1998/09/18 02:42:38 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -409,9 +409,23 @@ bool pkgSrcCacheCheck(pkgSourceList &List)
       _error->Discard();
       return false;
    }
-      
+
+   // Count the number of missing files
+   int Missing = 0;
+   for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
+   {
+      string File = ListDir + URItoFileName(I->PackagesURI());
+      struct stat Buf;
+      if (stat(File.c_str(),&Buf) != 0)
+      {
+        _error->WarningE("stat","Couldn't stat source package list '%s' (%s)",
+                         I->PackagesInfo().c_str(),File.c_str());       
+        Missing++;
+      }      
+   }
+   
    // They are certianly out of sync
-   if (Cache.Head().PackageFileCount != List.size())
+   if (Cache.Head().PackageFileCount != List.size() - Missing)
       return false;
    
    for (pkgCache::PkgFileIterator F(Cache); F.end() == false; F++)
@@ -572,7 +586,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
       {
         string File = ListDir + URItoFileName(I->PackagesURI());
         if (stat(File.c_str(),&Buf) != 0)
-           return _error->Errno("stat","Couldn't stat source package list %s",File.c_str());
+           continue;
         TotalSize += Buf.st_size;
       }
       
@@ -584,6 +598,10 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress)
       for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++)
       {
         string File = ListDir + URItoFileName(I->PackagesURI());
+
+        if (stat(File.c_str(),&Buf) != 0)
+           continue;
+        
         FileFd Pkg(File,FileFd::ReadOnly);
         debListParser Parser(Pkg);
         Progress.OverallProgress(CurrentSize,TotalSize,Pkg.Size(),"Reading Package Lists");