Просмотр исходного кода

apt-get update works now
Author: jgg
Date: 1998-11-12 04:10:52 GMT
apt-get update works now

Arch Librarian лет назад: 22
Родитель
Сommit
7a7fa5f07e
4 измененных файлов с 60 добавлено и 9 удалено
  1. 6 5
      apt-pkg/acquire-item.cc
  2. 44 2
      apt-pkg/acquire.cc
  3. 4 1
      apt-pkg/acquire.h
  4. 6 1
      cmdline/apt-get.cc

+ 6 - 5
apt-pkg/acquire-item.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-item.cc,v 1.9 1998/11/11 06:54:13 jgg Exp $
+// $Id: acquire-item.cc,v 1.10 1998/11/12 04:10:52 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Item - Item to acquire
    Acquire Item - Item to acquire
@@ -168,13 +168,14 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
       FinalFile += URItoFileName(Location->PackagesURI());
       FinalFile += URItoFileName(Location->PackagesURI());
       Rename(DestFile,FinalFile);
       Rename(DestFile,FinalFile);
       
       
+      /* We restore the original name to DestFile so that the clean operation
+         will work OK */
+      DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+      DestFile += URItoFileName(Location->PackagesURI());
+      
       // Remove the compressed version.
       // Remove the compressed version.
       if (Erase == true)
       if (Erase == true)
-      {
-	 DestFile = _config->FindDir("Dir::State::lists") + "partial/";
-	 DestFile += URItoFileName(Location->PackagesURI());
 	 unlink(DestFile.c_str());
 	 unlink(DestFile.c_str());
-      }      
       return;
       return;
    }
    }
 
 

+ 44 - 2
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.13 1998/11/11 23:45:08 jgg Exp $
+// $Id: acquire.cc,v 1.14 1998/11/12 04:10:54 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -23,6 +23,7 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <strutl.h>
 #include <strutl.h>
 
 
+#include <dirent.h>
 #include <sys/time.h>
 #include <sys/time.h>
 									/*}}}*/
 									/*}}}*/
 
 
@@ -343,7 +344,48 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
    return I->NextAcquire;
    return I->NextAcquire;
 };
 };
 									/*}}}*/
 									/*}}}*/
-
+// pkgAcquire::Clean - Cleans a directory				/*{{{*/
+// ---------------------------------------------------------------------
+/* This is a bit simplistic, it looks at every file in the dir and sees
+   if it is part of the download set. */
+bool pkgAcquire::Clean(string Dir)
+{
+   DIR *D = opendir(Dir.c_str());   
+   if (D == 0)
+      return _error->Errno("opendir","Unable to read %s",Dir.c_str());
+   
+   string StartDir = SafeGetCWD();
+   if (chdir(Dir.c_str()) != 0)
+   {
+      closedir(D);
+      return _error->Errno("chdir","Unable to change to ",Dir.c_str());
+   }
+   
+   for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
+   {
+      // Skip some files..
+      if (strcmp(Dir->d_name,"lock") == 0 ||
+	  strcmp(Dir->d_name,"partial") == 0 ||
+	  strcmp(Dir->d_name,".") == 0 ||
+	  strcmp(Dir->d_name,"..") == 0)
+	 continue;
+      
+      // Look in the get list
+      vector<Item *>::iterator I = Items.begin();
+      for (; I != Items.end(); I++)
+	 if (flNotDir((*I)->DestFile) == Dir->d_name)
+	    break;
+      
+      // Nothing found, nuke it
+      if (I == Items.end())
+	 unlink(Dir->d_name);
+   };
+   
+   chdir(StartDir.c_str());
+   closedir(D);
+   return true;   
+}
+									/*}}}*/
 // Acquire::MethodConfig::MethodConfig - Constructor			/*{{{*/
 // Acquire::MethodConfig::MethodConfig - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */

+ 4 - 1
apt-pkg/acquire.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.h,v 1.10 1998/11/11 06:54:17 jgg Exp $
+// $Id: acquire.h,v 1.11 1998/11/12 04:10:55 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -98,6 +98,9 @@ class pkgAcquire
    Worker *WorkerStep(Worker *I);
    Worker *WorkerStep(Worker *I);
    inline Item **ItemsBegin() {return Items.begin();};
    inline Item **ItemsBegin() {return Items.begin();};
    inline Item **ItemsEnd() {return Items.end();};
    inline Item **ItemsEnd() {return Items.end();};
+
+   // Cleans out the download dir
+   bool Clean(string Dir);
    
    
    pkgAcquire(pkgAcquireStatus *Log = 0);
    pkgAcquire(pkgAcquireStatus *Log = 0);
    ~pkgAcquire();
    ~pkgAcquire();

+ 6 - 1
cmdline/apt-get.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-get.cc,v 1.6 1998/11/11 23:45:56 jgg Exp $
+// $Id: apt-get.cc,v 1.7 1998/11/12 04:10:56 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    apt-get - Cover for dpkg
    apt-get - Cover for dpkg
@@ -472,6 +472,11 @@ bool DoUpdate(CommandLine &)
    if (Fetcher.Run() == false)
    if (Fetcher.Run() == false)
       return false;
       return false;
 
 
+   // Clean out any old list files
+   if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false ||
+       Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
+      return false;
+   
    // Prepare the cache.   
    // Prepare the cache.   
    CacheFile Cache;
    CacheFile Cache;
    if (Cache.Open() == false)
    if (Cache.Open() == false)