Skip to content

Commit 1988db3

Browse files
committed
🚑 Fix partition sizes in the custom partitioning view
1 parent 671e62f commit 1988db3

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/Views/DiskView.vala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ public class Installer.DiskView : OptionsView {
4646
unowned Distinst.InstallOptions options = install_options.get_updated_options ();
4747

4848
foreach (unowned Distinst.EraseOption disk in options.get_erase_options ()) {
49+
uint64 sectors = disk.get_sectors ();
4950
uint64 sector_size = disk.get_sector_size ();
51+
5052
string logo = Utils.string_from_utf8 (disk.get_linux_icon ());
5153
string label = Utils.string_from_utf8 (disk.get_model ());
54+
5255
string details = "%s %.1f GiB".printf (
5356
Utils.string_from_utf8 (disk.get_device_path ()),
54-
(double) disk.get_sectors () / (double) Utils.normalize_sectors(SECTORS_AS_GIB, sector_size)
57+
(double) sectors / (double) Utils.normalize_sectors (SECTORS_AS_GIB, sector_size)
5558
);
5659

5760
// Ensure that the user cannot select a disk that is too large for BIOS installs.
5861
bool msdos_too_large =
5962
Distinst.bootloader_detect () == Distinst.PartitionTable.MSDOS
60-
&& disk.get_sectors () > MSDOS_MAX_SECTORS;
63+
&& sectors > MSDOS_MAX_SECTORS;
6164

6265
base.add_option(logo, label, details, (button) => {
6366
if (disk.meets_requirements () && !msdos_too_large) {

src/Views/PartitioningView.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
192192
partitions.add (partition);
193193
}
194194

195-
var disk_bar = new DiskBar (model, path, size, (owned) partitions);
195+
var disk_bar = new DiskBar (model, path, size, sector_size, (owned) partitions);
196196
label_sizer.add_widget (disk_bar.label);
197197
disk_list.pack_start (disk_bar);
198198
}
@@ -248,7 +248,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
248248
}
249249
}
250250

251-
var disk_bar = new DiskBar (model, path, size, (owned) partitions);
251+
var disk_bar = new DiskBar (model, path, size, sector_size, (owned) partitions);
252252
label_sizer.add_widget (disk_bar.label);
253253
disk_list.pack_start (disk_bar);
254254
}

src/Widgets/DiskBar.vala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Installer.DiskBar: Gtk.Grid {
2222
public string disk_name { get; construct; }
2323
public string disk_path { get; construct; }
2424
public uint64 size { get; construct; }
25+
public uint64 sector_size { get; construct; }
2526
public Gee.ArrayList<PartitionBar> partitions { get; construct; }
2627

2728
public Gtk.Box label;
@@ -34,13 +35,15 @@ public class Installer.DiskBar: Gtk.Grid {
3435
string model,
3536
string path,
3637
uint64 size,
38+
uint64 sector_size,
3739
Gee.ArrayList<PartitionBar> partitions
3840
) {
3941
Object (
4042
disk_name: model,
4143
disk_path: path,
4244
partitions: partitions,
43-
size: size
45+
size: size,
46+
sector_size: sector_size
4447
);
4548
}
4649

@@ -66,7 +69,7 @@ public class Installer.DiskBar: Gtk.Grid {
6669
used += partition.get_size ();
6770
}
6871

69-
return size - (used * 512);
72+
return size - (used * sector_size);
7073
}
7174

7275
private void generate_legend () {
@@ -79,7 +82,7 @@ public class Installer.DiskBar: Gtk.Grid {
7982
legend.add (legend_container);
8083

8184
foreach (PartitionBar p in partitions) {
82-
add_legend (p.path, p.get_size () * 512, Distinst.strfilesys (p.filesystem), p.vg, p.menu);
85+
add_legend (p.path, p.get_size () * sector_size, Distinst.strfilesys (p.filesystem), p.vg, p.menu);
8386
}
8487

8588
if (size / 100 < unused) {
@@ -165,7 +168,7 @@ public class Installer.DiskBar: Gtk.Grid {
165168

166169
private void update_sector_lengths (Gee.ArrayList<PartitionBar> partitions, Gtk.Allocation alloc) {
167170
var alloc_width = alloc.width;
168-
var disk_sectors = this.size / 512;
171+
var disk_sectors = this.size / sector_size;
169172

170173
int[] lengths = {};
171174
for (int x = 0; x < partitions.size; x++) {

0 commit comments

Comments
 (0)