From 6b71e3de8f455b215ba91baf0f75155ada98968c Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 21 May 2018 12:37:08 -0600 Subject: [PATCH] Only update disk options when the device layout has changed --- src/MainWindow.vala | 1 + src/Objects/InstallOptions.vala | 28 ++++++++++++++++++++++------ src/Views/DiskView.vala | 3 +-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b1a9598c9..0107c1118 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -61,6 +61,7 @@ public class Installer.MainWindow : Gtk.Dialog { get_style_context ().add_class ("os-installer"); minimum_disk_size = Distinst.minimum_disk_size (5000000000); + InstallOptions.get_default ().set_minimum_size (minimum_disk_size); language_view.next_step.connect (() => load_keyboard_view ()); } diff --git a/src/Objects/InstallOptions.vala b/src/Objects/InstallOptions.vala index 41082cabc..3dbdad4de 100644 --- a/src/Objects/InstallOptions.vala +++ b/src/Objects/InstallOptions.vala @@ -20,6 +20,8 @@ public class InstallOptions : GLib.Object { private static InstallOptions _options_object; + private uint64 minimum_size; + private uint64 layout_hash; private Distinst.InstallOptions _options; private Distinst.Disks disks; public Distinst.InstallOption? selected_option; @@ -32,6 +34,10 @@ public class InstallOptions : GLib.Object { return _options_object; } + public void set_minimum_size (uint64 size) { + minimum_size = size; + } + public bool has_recovery () { return null != get_options().get_recovery_option (); } @@ -41,16 +47,26 @@ public class InstallOptions : GLib.Object { return null != recovery && recovery.get_oem_mode (); } - public unowned Distinst.InstallOptions new_options (uint64 minimum_disk_size) { - disks = Distinst.Disks.probe (); - _options = new Distinst.InstallOptions (disks, minimum_disk_size); + public unowned Distinst.InstallOptions get_options () { + if (null == _options) { + disks = Distinst.Disks.probe (); + disks.initialize_volume_groups (); + layout_hash = Distinst.device_layout_hash (); + _options = new Distinst.InstallOptions (disks, minimum_size); + } + return _options; } - public unowned Distinst.InstallOptions get_options () { - if (null == _options) { + // Returns an updated option if the device layout has changed. + public unowned Distinst.InstallOptions get_updated_options () { + var new_hash = Distinst.device_layout_hash (); + if (layout_hash != new_hash) { + stderr.printf ("layout changed\n"); + layout_hash = new_hash; disks = Distinst.Disks.probe (); - _options = new Distinst.InstallOptions (disks, 0); + _options = new Distinst.InstallOptions (disks, minimum_size); + selected_option = null; } return _options; diff --git a/src/Views/DiskView.vala b/src/Views/DiskView.vala index 93e52c375..d835db79d 100644 --- a/src/Views/DiskView.vala +++ b/src/Views/DiskView.vala @@ -104,8 +104,7 @@ public class Installer.DiskView : AbstractInstallerView { DiskButton[] enabled_buttons = {}; DiskButton[] disabled_buttons = {}; - unowned Distinst.InstallOptions install_options = InstallOptions.get_default () - .new_options (minimum_disk_size); + unowned Distinst.InstallOptions install_options = InstallOptions.get_default ().get_updated_options (); if (install_options == null) { critical (_("unable to get installation options"));