[gnome-boxes] installer: Remove redundant loop



commit e8939971dd4515fcfebc292dd0618e007a3b08bf
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Feb 28 15:35:19 2013 +0200

    installer: Remove redundant loop
    
    Once the drivers are setup, they are setup for all scripts that can use
    them. There is no need to keep setting them up for every script.
    
    Also if there is going to be multiple scripts in the desktop profile
    supporting same type (pre- or post-installable) of drivers, Boxes will be
    copying them multiple times. That is not a big issue in case of
    pre-installable drivers but in case of post-installable drivers, the
    mkisofs commandline we use to setup postinstallation drivers will fail.
    
    This patch fixes that potential issue as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694872

 src/unattended-installer.vala |   51 +++++++++++++++-------------------------
 1 files changed, 19 insertions(+), 32 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 98eaf8f..23c36bb 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -663,11 +663,10 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
 
         if (drivers.length () != 0 && scripts.length () != 0) {
             var drivers_progress = progress.add_child_activity (0.5);
-            var setup_drivers = yield setup_drivers_for_scripts (drivers,
-                                                                 scripts,
-                                                                 drivers_progress,
-                                                                 add_unattended_file,
-                                                                 cancellable);
+            var setup_drivers = yield setup_drivers_from_list (drivers,
+                                                               drivers_progress,
+                                                               add_unattended_file,
+                                                               cancellable);
 
             foreach (var driver in setup_drivers) {
                 foreach (var d in driver.get_devices ().get_elements ()) {
@@ -688,50 +687,38 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
 
         if (drivers.length () != 0 && scripts.length () != 0) {
             var drivers_progress = progress.add_child_activity (0.5);
-            yield setup_drivers_for_scripts (drivers,
-                                             scripts,
-                                             drivers_progress,
-                                             add_secondary_unattended_file,
-                                             cancellable);
+            yield setup_drivers_from_list (drivers, drivers_progress, add_secondary_unattended_file, 
cancellable);
         } else
             progress.progress = 1.0;
     }
 
-    private async GLib.List<DeviceDriver> setup_drivers_for_scripts
+    private async GLib.List<DeviceDriver> setup_drivers_from_list
                                 (GLib.List<DeviceDriver>  drivers,
-                                 GLib.List<InstallScript> scripts,
                                  ActivityProgress         progress,
                                  AddUnattendedFileFunc    add_func,
                                  Cancellable?             cancellable = null) {
         var setup_drivers = new GLib.List<DeviceDriver> ();
-        var driver_progress_scale = 1d / drivers.length () / scripts.length ();
+        var driver_progress_scale = 1d / drivers.length ();
 
         foreach (var driver in drivers) {
-            foreach (var script in scripts) {
-                var driver_progress = progress.add_child_activity (driver_progress_scale);
-                try {
-                    yield setup_driver_for_script (driver,
-                                                   script,
-                                                   driver_progress,
-                                                   add_func,
-                                                   cancellable);
-                    setup_drivers.append (driver);
-                } catch (GLib.Error e) {
-                    debug ("Failed to make use of drivers at '%s': %s", driver.get_location (), e.message);
-                } finally {
-                    driver_progress.progress = 1.0; // Ensure progress reaches 100%
-                }
+            var driver_progress = progress.add_child_activity (driver_progress_scale);
+            try {
+                yield setup_driver (driver, driver_progress, add_func, cancellable);
+                setup_drivers.append (driver);
+            } catch (GLib.Error e) {
+                debug ("Failed to make use of drivers at '%s': %s", driver.get_location (), e.message);
+            } finally {
+                driver_progress.progress = 1.0; // Ensure progress reaches 100%
             }
         }
 
         return setup_drivers;
     }
 
-    private async void setup_driver_for_script (DeviceDriver          driver,
-                                                InstallScript         script,
-                                                ActivityProgress      progress,
-                                                AddUnattendedFileFunc add_func,
-                                                Cancellable?          cancellable) throws GLib.Error {
+    private async void setup_driver (DeviceDriver          driver,
+                                     ActivityProgress      progress,
+                                     AddUnattendedFileFunc add_func,
+                                     Cancellable?          cancellable) throws GLib.Error {
 
         var downloader = Downloader.get_instance ();
 


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