[gnome-boxes] fedora: Simplify extract_boot_files



commit 2378883ccc2711d2398911f2827007a8e06cad00
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Thu Jul 12 18:38:47 2012 +0200

    fedora: Simplify extract_boot_files
    
    It was reusing several times the same variables for different
    purposes, including assigning a temporary value to member variables
    to override them later on.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679752

 src/fedora-installer.vala |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/fedora-installer.vala b/src/fedora-installer.vala
index a6526af..52ae178 100644
--- a/src/fedora-installer.vala
+++ b/src/fedora-installer.vala
@@ -115,27 +115,26 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
     }
 
     private async void extract_boot_files (Cancellable? cancellable) throws GLib.Error {
-        string kernel_path = Path.build_filename (mount_point, os_media.kernel_path);
-        kernel_file = File.new_for_path (kernel_path);
-        string initrd_path = Path.build_filename (mount_point, os_media.initrd_path);
-        initrd_file = File.new_for_path (initrd_path);
-
         if (!mounted)
             return;
 
-        kernel_path = get_user_unattended ("kernel");
-        kernel_file = yield copy_file (kernel_file, kernel_path, cancellable);
-        initrd_path = get_user_unattended ("initrd");
-        initrd_file = yield copy_file (initrd_file, initrd_path, cancellable);
+        string src_path = Path.build_filename (mount_point, os_media.kernel_path);
+        string dest_path = get_user_unattended ("kernel");
+        kernel_file = yield copy_file (src_path, dest_path, cancellable);
+
+        src_path = Path.build_filename (mount_point, os_media.initrd_path);
+        dest_path = get_user_unattended ("initrd");
+        initrd_file = yield copy_file (src_path, dest_path, cancellable);
     }
 
-    private async File copy_file (File file, string dest_path, Cancellable? cancellable) throws GLib.Error {
+    private async File copy_file (string src_path, string dest_path, Cancellable? cancellable) throws GLib.Error {
+        var src_file = File.new_for_path (src_path);
         var dest_file = File.new_for_path (dest_path);
 
         try {
-            debug ("Copying '%s' to '%s'..", file.get_path (), dest_path);
-            yield file.copy_async (dest_file, 0, Priority.DEFAULT, cancellable);
-            debug ("Copied '%s' to '%s'.", file.get_path (), dest_path);
+            debug ("Copying '%s' to '%s'..", src_path, dest_path);
+            yield src_file.copy_async (dest_file, 0, Priority.DEFAULT, cancellable);
+            debug ("Copied '%s' to '%s'.", src_path, dest_path);
         } catch (IOError.EXISTS error) {}
 
         return dest_file;



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