]> git.saurik.com Git - apt.git/commitdiff
Made apt-cache regenerate its cache in memory
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:36 +0000 (16:53 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:36 +0000 (16:53 +0000)
Author: jgg
Date: 1999-04-19 02:35:38 GMT
Made apt-cache regenerate its cache in memory

apt-pkg/cachefile.cc
apt-pkg/pkgcachegen.cc
cmdline/apt-cache.cc

index 285eb310f8f1108feb2b8f16837e74e029287307..88c3fa81a4ed154988ea89455b72e0dec2463d0f 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cachefile.cc,v 1.1 1999/04/18 06:36:36 jgg Exp $
+// $Id: cachefile.cc,v 1.2 1999/04/19 02:35:38 jgg Exp $
 /* ######################################################################
    
    CacheFile - Simple wrapper class for opening, generating and whatnot
@@ -86,10 +86,9 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock)
    
    // Create the dependency cache
    Cache = new pkgDepCache(*Map,Progress);
+   Progress.Done();
    if (_error->PendingError() == true)
       return false;
-
-   Progress.Done();
    
    return true;
 }
index 1e31ff3003cab9fa1d033be8b6c3c8bd975b28b2..fd4f8965b4775ae603e79081cf9a57b0a12315f4 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.cc,v 1.36 1999/04/18 07:25:32 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.37 1999/04/19 02:35:38 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -26,6 +26,7 @@
 
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
                                                                        /*}}}*/
 
 // CacheGenerator::pkgCacheGenerator - Constructor                     /*{{{*/
@@ -761,7 +762,9 @@ MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
    /* If the cache file is writeable this is just a wrapper for
       MakeStatusCache */
    string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
-   bool Writeable = access(CacheFile.c_str(),W_OK) == 0;
+   bool Writeable = (access(CacheFile.c_str(),W_OK) == 0) ||
+                    (errno == ENOENT);
+
    if (Writeable == true)
    {
       if (pkgMakeStatusCache(List,Progress) == false)
index 3f50f0c02b6d9c69ad77c1c6c175d2c90ed9af87..9a404e5be9cb09a18815bf2da434317f67adc7ce 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-cache.cc,v 1.33 1999/04/12 04:21:20 jgg Exp $
+// $Id: apt-cache.cc,v 1.34 1999/04/19 02:35:38 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -658,15 +658,20 @@ int main(int argc,const char *argv[])
    if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
    {      
       // Open the cache file
-      FileFd CacheF(_config->FindFile("Dir::Cache::pkgcache"),FileFd::ReadOnly);
-      MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
+      pkgSourceList List;
+      List.ReadMainList();
+
+      // Generate it and map it
+      OpProgress Prog;
+      MMap *Map = pkgMakeStatusCacheMem(List,Prog);
       if (_error->PendingError() == false)
       {
-        pkgCache Cache(Map);   
+        pkgCache Cache(*Map);   
         GCache = &Cache;
         if (_error->PendingError() == false)
            CmdL.DispatchArg(CmdsB);
-      }      
+      }
+      delete Map;
    }
    
    // Print any errors or warnings found during parsing