Skip to content

Commit

Permalink
truncate percentages, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmhewitt committed Dec 12, 2024
1 parent acfdcc3 commit 9d73b9a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,74 @@ public class Installer.PartitioningView : AbstractInstallerView {
partitions = {partitions_9, partitions_10}
};

var partitions_11 = InstallerDaemon.Partition () {
device_path = "/dev/nvme0n1p1",
filesystem = InstallerDaemon.FileSystem.FAT32,
start_sector = 4096,
end_sector = 542966,
sectors_used = InstallerDaemon.PartitionUsage () {
tag = 1,
value = 30312
},
current_lvm_volume_group = ""
};

var partitions_12 = InstallerDaemon.Partition () {
device_path = "/dev/nvme0n1p2",
filesystem = InstallerDaemon.FileSystem.LVM,
start_sector = 542968,
end_sector = 976769070,
sectors_used = InstallerDaemon.PartitionUsage () {
tag = 0,
value = 0
},
current_lvm_volume_group = "data"
};

physical_disks += InstallerDaemon.Disk () {
name = "Samsung SSD 970 EVO 500GB",
device_path = "/dev/nvme0n1",
sectors = 976773168,
sector_size = 512,
rotational = false,
removable = false,
partitions = {partitions_11, partitions_12}
};

var partitions_13 = InstallerDaemon.Partition () {
device_path = "/dev/dm-0",
filesystem = InstallerDaemon.FileSystem.EXT4,
start_sector = 0,
end_sector = 968220672,
sectors_used = InstallerDaemon.PartitionUsage () {
tag = 1,
value = 534569520
},
current_lvm_volume_group = ""
};

var partitions_14 = InstallerDaemon.Partition () {
device_path = "/dev/dm-1",
filesystem = InstallerDaemon.FileSystem.SWAP,
start_sector = 968220673,
end_sector = 976216065,
sectors_used = InstallerDaemon.PartitionUsage () {
tag = 0,
value = 0
},
current_lvm_volume_group = ""
};

logical_disks += InstallerDaemon.Disk () {
name = "LVM data",
device_path = "/dev/mapper/data",
sectors = 976226102,
sector_size = 512,
rotational = false,
removable = false,
partitions = {partitions_13, partitions_14}
};

return InstallerDaemon.DiskInfo () {
physical_disks = physical_disks,
logical_disks = logical_disks
Expand Down
3 changes: 3 additions & 0 deletions src/Widgets/DiskBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public class Installer.DiskBar: Gtk.Box {
}

private void append_partition (Gtk.Widget widget, double percentage) {
// Truncate to 2 decimal places (round down), to ensure we don't go over 100% because of rounding errors
percentage = (int)(percentage * 100) / 100.0;

widget.set_parent (this);

var layout_manager = ((Gtk.ConstraintLayout) get_layout_manager ());
Expand Down

0 comments on commit 9d73b9a

Please sign in to comment.