// -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.32 1999/06/06 06:58:36 jgg Exp $
+// $Id: acquire-item.cc,v 1.33 1999/07/10 05:32:25 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
 /* */
 void pkgAcqIndexRel::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 {
-   // This is the retry counter
    if (Cnf->LocalOnly == true || 
        StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
    {      
 
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-get.cc,v 1.69 1999/07/10 04:58:42 jgg Exp $
+// $Id: apt-get.cc,v 1.70 1999/07/10 05:32:26 jgg Exp $
 /* ######################################################################
    
    apt-get - Cover for dpkg
    if (Fetcher.Run() == pkgAcquire::Failed)
       return false;
 
+   bool Failed = false;
+   for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+   {
+      if ((*I)->Status == pkgAcquire::Item::StatDone)
+        continue;
+
+      (*I)->Finished();
+      
+      Failed = true;
+   }
+   
    // 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;
+   if (_config->FindB("APT::Get::List-Cleanup",false) == false)
+   {
+      if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false ||
+         Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
+        return false;
+   }
    
    // Prepare the cache.   
    CacheFile Cache;
    if (Cache.Open() == false)
       return false;
    
+   if (Failed == true)
+      return _error->Error("Some index files failed to download, they have been ignored, or old ones used instead.");
    return true;
 }
                                                                        /*}}}*/
    _config->Set("APT::Get::Assume-Yes",false);
    _config->Set("APT::Get::Fix-Broken",false);
    _config->Set("APT::Get::Force-Yes",false);
+   _config->Set("APT::Get::APT::Get::No-List-Cleanup",true);
 }
                                                                        /*}}}*/
 // SigWinch - Window size change signal handler                                /*{{{*/
       {0,"force-yes","APT::Get::force-yes",0},
       {0,"print-uris","APT::Get::Print-URIs",0},
       {0,"purge","APT::Get::Purge",0},
+      {0,"list-cleanup","APT::Get::List-Cleanup",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
       {0,0,0,0}};
 
 dit(bf(--purge))
 Use purge instead of remove for anything that would be removed.
 
+dit(bf(--list-cleanup))
+This option defaults to on, use bf(--no-list-cleanup) to turn it off.
+When on apt-get will automatically manage the contents of 
+/var/state/apt/lists to ensure that obsolete files are erased. The only 
+reason to turn it off is if you frequently change your source list.
+
 dit(bf(-c, --config-file))
 Configuration File; Specify a configuration file to use. bf(apt-get) will
 read the default configuration file and then this configuration file. See