[gnome-boxes] More robust installer media clean-up



commit 8c467bc2a50d56a4d61ab29ddb907ff53bd964d2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Jun 16 01:22:26 2012 +0300

    More robust installer media clean-up
    
    * Never mind if files to be deleted don't exist.
    * Unset some fields at clean-up to make InstallerMedia more re-entrant.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674209

 src/fedora-installer.vala |   12 ++++++------
 src/util.vala             |   10 ++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/fedora-installer.vala b/src/fedora-installer.vala
index ec7e015..de2b0db 100644
--- a/src/fedora-installer.vala
+++ b/src/fedora-installer.vala
@@ -81,15 +81,13 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
         base.clean_up ();
 
         if (kernel_file != null) {
-            debug ("Removing '%s'..", kernel_path);
-            kernel_file.delete ();
-            debug ("Removed '%s'.", kernel_path);
+            delete_file (kernel_file);
+            kernel_file = null;
         }
 
         if (initrd_file != null) {
-            debug ("Removing '%s'..", initrd_path);
-            initrd_file.delete ();
-            debug ("Removed '%s'.", initrd_path);
+            delete_file (initrd_file);
+            initrd_file = null;
         }
     }
 
@@ -110,9 +108,11 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
         debug ("Unmounting '%s'..", mount_point);
         string[] argv = { "fusermount", "-u", mount_point };
         yield exec (argv, cancellable);
+        mounted = false;
         debug ("Unmounted '%s'.", mount_point);
 
         source_dir.delete ();
+        mount_point = null;
         debug ("Removed '%s'.", mount_point);
     }
 
diff --git a/src/util.vala b/src/util.vala
index b75f970..4e29588 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -559,4 +559,14 @@ namespace Boxes {
             return false;
          });
     }
+
+    public void delete_file (File file) throws GLib.Error {
+        try {
+            debug ("Removing '%s'..", file.get_path ());
+            file.delete ();
+            debug ("Removed '%s'.", file.get_path ());
+        } catch (IOError.NOT_FOUND e) {
+            debug ("File '%s' was already deleted", file.get_path ());
+        }
+    }
 }



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