Skip to content

Commit c5f56c6

Browse files
filipskyHonza Filipsky
andauthored
Fix for parsing Disk.fromLsblk on older Linux (#11)
* Disk.fromLsblk parssing fix * fixed the code to compile * pushed forgotten line of code --------- Co-authored-by: Honza Filipsky <[email protected]>
1 parent cc1906b commit c5f56c6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/src/models/disk.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ class Disk extends Equatable {
165165
final scsi =
166166
RegExp(r"/^(sata|scsi|ata|ide|pci)$/i").hasMatch(device["tran"] ?? "");
167167
final usb = RegExp(r"/^(usb)$/i").hasMatch(device["tran"] ?? "");
168-
final readonly = device["ro"] == 1;
169-
final removable = device["rm"] == 1 || device["hotplug"] == 1 || virtual;
168+
final readonly = device["ro"]?.toString() == '1';
169+
final removable = device["rm"]?.toString() == '1'|| device["hotplug"]?.toString() == '1' || virtual;
170170

171171
return Disk(
172172
busType: (device["tran"] ?? "UNKNOWN").toUpperCase(),
173173
device: name ?? "",
174174
raw: kname ?? name ?? "",
175175
description: getDescription(),
176-
size: device["size"],
177-
blockSize: device["phy-sec"] ?? 512,
178-
logicalBlockSize: device["log-sec"] ?? 512,
176+
size: int.tryParse(device["size"]?.toString() ?? ""),
177+
blockSize: int.tryParse(device["phy-sec"]?.toString() ?? "") ?? 512,
178+
logicalBlockSize: int.tryParse(device["log-sec"]?.toString() ?? "") ?? 512,
179179
mountpoints: ((device["children"] ?? [device]) as List)
180180
.where((mountpoint) => mountpoint["mountpoint"] != null)
181181
.map((mountpoint) => Mountpoint.fromLsblk(mountpoint))

0 commit comments

Comments
 (0)