[gnome-continuous] builddisks: Clean up qcow2 files on error



commit 831b46bf00e871ac26e26116bfcf3c2476f683d9
Author: Colin Walters <walters verbum org>
Date:   Mon Jun 15 17:42:32 2015 -0400

    builddisks: Clean up qcow2 files on error
    
    They take up a lot of space.  If we need them to debug an error, we
    can reproduce locally.

 src/js/tasks/task-builddisks.js |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/js/tasks/task-builddisks.js b/src/js/tasks/task-builddisks.js
index 9fd4971..94a02fb 100644
--- a/src/js/tasks/task-builddisks.js
+++ b/src/js/tasks/task-builddisks.js
@@ -117,6 +117,8 @@ const TaskBuildDisks = new Lang.Class({
                     params.sizeMB = 4 * 1024;
                 LibQA.createDisk(diskPath, params, cancellable);
             }
+            // Not indented to avoid too much code motion
+            try {
             let tmpdir_path = Gio.File.new_for_path(GLib.dir_make_tmp("continuous-XXXXXX"));
             let mntdir = tmpdir_path.get_child('mnt-' + squashedName);
             GSystem.file_ensure_directory(mntdir, true, cancellable);
@@ -138,6 +140,10 @@ const TaskBuildDisks = new Lang.Class({
 
             this._postDiskCreation(squashedName, diskPath, cancellable);
             print("post-disk creation complete");
+            } catch (e) {
+                GSystem.shutil_rm_rf(diskPath, cancellable);
+                throw e;
+            }
              }
 
         if (isLocal) {


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