[Aptitude-svn-commit] r4277 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Mon Sep 26 05:27:47 UTC 2005


Author: dburrows
Date: Mon Sep 26 05:27:43 2005
New Revision: 4277

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Actually pop up warnings when a read-only cache is modified.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Sep 26 05:27:43 2005
@@ -1,5 +1,13 @@
 2005-09-25  Daniel Burrows  <dburrows at debian.org>
 
+	* src/ui.cc:
+
+	  Connect up the new cache functions to display a helpful (?)
+	  message when a read-only cache is modified.  This enforces a
+	  rule that modifying the cache during a download is Not Allowed,
+	  and it resets the cache to not-read-only after displaying a
+	  single warning message otherwise.
+
 	* src/generic/aptcache.cc, src/generic/aptcache.h:
 
 	  Add support for making the cache 'read-only'; writing to a

Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc	Mon Sep 26 05:27:43 2005
@@ -264,6 +264,35 @@
     error_dialog_layout->append_fragment(apt_error_fragment());
 }
 
+static bool do_read_only_permission()
+{
+  if(active_download)
+    return false;
+  else
+    {
+      // Only display this message once.
+      show_message(_("WARNING: the package cache is opened in read-only mode!  This change and all subsequent changes will not be saved unless you stop all other running apt-based programs and select \"Become root\" from the Actions menu."));
+      (*apt_cache_file)->set_read_only(false);
+      return true;
+    }
+}
+
+static void do_read_only_fail()
+{
+  assert(active_download);
+
+  show_message(_("You may not modify the state of any package while a download is proceeding."));
+}
+
+static void do_connect_read_only_callbacks()
+{
+  if(apt_cache_file != NULL)
+    {
+      (*apt_cache_file)->read_only_permission.connect(sigc::ptr_fun(&do_read_only_permission));
+      (*apt_cache_file)->read_only_fail.connect(sigc::ptr_fun(&do_read_only_fail));
+    }
+}
+
 // Runs a sub-aptitude with the same selections that the user
 // has currently made, but as root.
 //
@@ -2145,6 +2174,10 @@
     }
   cache_reload_failed.connect(sigc::ptr_fun(do_hide_reload_message));
 
+  cache_reloaded.connect(sigc::ptr_fun(do_connect_read_only_callbacks));
+  if(apt_cache_file)
+    do_connect_read_only_callbacks();
+
   add_menu(actions_menu, _("Actions"), menu_description);
   add_menu(undo_menu, _("Undo"), menu_description);
   add_menu(package_menu, _("Package"), menu_description);



More information about the Aptitude-svn-commit mailing list