[Aptitude-svn-commit] r4306 - in branches/aptitude-0.3/aptitude: . src/generic/apt

Daniel Burrows dburrows at costa.debian.org
Mon Sep 26 22:12:18 UTC 2005


Author: dburrows
Date: Mon Sep 26 22:12:15 2005
New Revision: 4306

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/apt/aptcache.cc
Log:
Save one backup of pkgstates automatically.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Sep 26 22:12:15 2005
@@ -1,5 +1,11 @@
 2005-09-26  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/apt/aptcache.cc:
+
+	  Preserve the last version of pkgstates when saving the selection
+	  list. (Closes: #316460)  Also, don't remove the .new version if
+	  we fail to save the cache (so the user can manually recover).
+
 	* src/ui.cc:
 
 	  Write a better description for the flat package list viewer.

Modified: branches/aptitude-0.3/aptitude/src/generic/apt/aptcache.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/apt/aptcache.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/apt/aptcache.cc	Mon Sep 26 22:12:15 2005
@@ -603,10 +603,26 @@
       //       wouldn't be harmful; you'd just get gratuitous errors..
       if(!status_fname)
 	{
-	  if(rename((statefile+".new").c_str(), statefile.c_str())==-1)
+	  string oldstr(statefile + ".old"), newstr(statefile + ".new");
+
+	  if(unlink(oldstr.c_str()) != 0 && errno != ENOENT)
+	    {
+	      _error->Errno("save_selection_list", _("failed to remove %s"), oldstr.c_str());
+	      prog.Done();
+	      return false;
+	    }
+
+	  if(link(statefile.c_str(), oldstr.c_str()) != 0)
+	    {
+	      _error->Errno("save_selection_list", _("failed to rename %s to %s"),
+			    statefile.c_str(), (statefile + ".old").c_str());
+	      prog.Done();
+	      return false;
+	    }
+
+	  if(rename(newstr.c_str(), statefile.c_str()) != 0)
 	    {
-	      _error->Errno("save_selection_list", _("couldn't replace old state file"));
-	      unlink((statefile+".new").c_str());
+	      _error->Errno("save_selection_list", _("couldn't replace %s with %s"), statefile.c_str(), newstr.c_str());
 	      prog.Done();
 	      return false;
 	    }



More information about the Aptitude-svn-commit mailing list