Skip to content

Commit

Permalink
Fix: exception raised if partition data is missing for dos partition …
Browse files Browse the repository at this point in the history
…on an USB HDD (issue #6).
  • Loading branch information
petersulyok committed Apr 6, 2024
1 parent 17a2719 commit 492a1d9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/diskinfo/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,18 @@ def __init__(self, name: str, dev_id: str) -> None:
self.__part_label = _read_udev_property(path, "ID_PART_ENTRY_NAME=")
self.__part_uuid = _read_udev_property(path, "ID_PART_ENTRY_UUID=")
self.__part_type = _read_udev_property(path, "ID_PART_ENTRY_TYPE=")
self.__part_number = int(_read_udev_property(path, "ID_PART_ENTRY_NUMBER="))
self.__part_offset = int(_read_udev_property(path, "ID_PART_ENTRY_OFFSET="))
self.__part_size = int(_read_udev_property(path, "ID_PART_ENTRY_SIZE="))
self.__part_number = 0
value = _read_udev_property(path, "ID_PART_ENTRY_NUMBER=")
if value:
self.__part_number = int(value)
self.__part_offset = -1
value = _read_udev_property(path, "ID_PART_ENTRY_OFFSET=")
if value:
self.__part_offset = int(value)
self.__part_size = 0
value = _read_udev_property(path, "ID_PART_ENTRY_SIZE=")
if value:
self.__part_size = int(value)
value = _read_udev_property(path, "ID_FS_LABEL_ENC=")
if value:
self.__fs_label = value
Expand Down

0 comments on commit 492a1d9

Please sign in to comment.