[system-tools-backends-clone] Don't reload whole groups configuration on every individual change



commit bd607d9be07d9ad001e282525588cfea8667039a
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Sun Mar 14 15:51:31 2010 +0100

    Don't reload whole groups configuration on every individual change
    
    Load the config once when committing, to avoid reloading it many times when committing the whole GroupsConfig.

 Users/Groups.pm |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/Users/Groups.pm b/Users/Groups.pm
index da492ad..f68d9b4 100644
--- a/Users/Groups.pm
+++ b/Users/Groups.pm
@@ -301,14 +301,27 @@ sub get_files
 sub set
 {
   my ($config) = @_;
+  my ($groups) = &get ();
+  my ($new_group, $group);
 
   return if (!$config);
 
+
+  # Make backups manually, otherwise they don't get backed up.
+  &Utils::File::do_backup ($group_names);
+
   # Change groups that are present in both old and new config.
   # Groups won't be removed or added this way, for more safety.
-  foreach $group (@$config)
+  foreach $new_group (@$config)
   {
-    set_group ($group);
+    foreach $group (@$groups)
+    {
+      if ($$new_group[$GID] == $$group[$GID])
+      {
+        &change_group ($group, $new_group);
+        break;
+      }
+  }
   }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]