[gnome-boxes] installer-media: prepare() return true on success
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] installer-media: prepare() return true on success
- Date: Mon, 27 Oct 2014 18:52:19 +0000 (UTC)
commit ea755cb958ceed155ea3d06ac4b2f94e8f0cce54
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Mon Oct 27 17:23:57 2014 +0100
installer-media: prepare() return true on success
This allows callers to handle cancellation/failure.
https://bugzilla.gnome.org/show_bug.cgi?id=725386
src/installer-media.vala | 7 +++++--
src/unattended-installer.vala | 25 +++++++++++++++++--------
2 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index a520b14..7a23cde 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -82,8 +82,11 @@ private class Boxes.InstallerMedia : GLib.Object {
}
public virtual void set_direct_boot_params (DomainOs os) {}
- public virtual async void prepare (ActivityProgress progress = new ActivityProgress (),
- Cancellable? cancellable = null) {}
+ // Returns true on success, false otherwise
+ public virtual async bool prepare (ActivityProgress progress = new ActivityProgress (),
+ Cancellable? cancellable = null) {
+ return true;
+ }
public virtual async void prepare_for_installation (string vm_name, Cancellable? cancellable) {}
public virtual void prepare_to_continue_installation (string vm_name) {}
public virtual void clean_up () {
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 48116fe..87e4463 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -338,9 +338,9 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
return get_user_pkgcache (filename);
}
- public override async void prepare (ActivityProgress progress = new ActivityProgress (),
- Cancellable? cancellable = null) {
- yield setup_drivers (progress, cancellable);
+ public override async bool prepare (ActivityProgress progress = new ActivityProgress (),
+ Cancellable? cancellable = null) {
+ return yield setup_drivers (progress, cancellable);
}
private DomainDisk? get_unattended_disk_config (PathFormat path_format = PathFormat.UNIX) {
@@ -461,7 +461,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
private delegate void AddUnattendedFileFunc (UnattendedFile file);
- private async void setup_drivers (ActivityProgress progress, Cancellable? cancellable = null) {
+ private async bool setup_drivers (ActivityProgress progress, Cancellable? cancellable = null) {
progress.info = _("Downloading device drivers…");
var scripts = get_pre_installer_scripts ();
@@ -469,7 +469,8 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
if (drivers.length () != 0 && scripts.length () != 0) {
var drivers_progress = progress.add_child_activity (0.5);
- yield setup_drivers_from_list (drivers, drivers_progress, add_unattended_file, cancellable);
+ if (!yield setup_drivers_from_list (drivers, drivers_progress, add_unattended_file, cancellable))
+ return false;
} else
progress.progress = 0.5;
@@ -478,12 +479,14 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
if (drivers.length () != 0 && scripts.length () != 0) {
var drivers_progress = progress.add_child_activity (0.5);
- yield setup_drivers_from_list (drivers, drivers_progress, add_secondary_unattended_file,
cancellable);
+ return yield setup_drivers_from_list (drivers, drivers_progress, add_secondary_unattended_file,
cancellable);
} else
progress.progress = 1.0;
+
+ return true;
}
- private async void setup_drivers_from_list (GLib.List<DeviceDriver> drivers,
+ private async bool setup_drivers_from_list (GLib.List<DeviceDriver> drivers,
ActivityProgress progress,
AddUnattendedFileFunc add_func,
Cancellable? cancellable = null) {
@@ -494,12 +497,18 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
try {
yield setup_driver (driver, driver_progress, add_func, cancellable);
additional_devices.add_all (driver.get_devices ());
+ } catch (IOError.CANCELLED e) {
+ debug ("Media preparation cancelled during driver setup.");
+
+ return false;
} 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 true;
}
private async void setup_driver (DeviceDriver driver,
@@ -527,7 +536,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
cached_paths += system_cached_path;
var file_progress = progress.add_child_activity (file_progress_scale);
- file = yield downloader.download (file, cached_paths, file_progress);
+ file = yield downloader.download (file, cached_paths, file_progress, cancellable);
file_progress.progress = 1.0; // Ensure progress reaches 100%
driver_files.append (new UnattendedRawFile (this, file.get_path (), filename));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]