Skip to content

Commit

Permalink
Only update disk options when the device layout has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed May 21, 2018
1 parent 67d0ef7 commit 6b71e3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/MainWindow.vala
Expand Up @@ -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 ());
}
Expand Down
28 changes: 22 additions & 6 deletions src/Objects/InstallOptions.vala
Expand Up @@ -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;
Expand All @@ -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 ();
}
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Views/DiskView.vala
Expand Up @@ -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"));
Expand Down

0 comments on commit 6b71e3d

Please sign in to comment.