Skip to content

Commit

Permalink
Default to unknown on partition types (#2037)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Girtler <[email protected]>
  • Loading branch information
svartkanin and svartkanin authored Sep 14, 2023
1 parent 2252dcf commit c8e0b9a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions archinstall/lib/disk/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ..general import SysCommand
from ..output import debug, error
from ..storage import storage
from ..output import info

if TYPE_CHECKING:
_: Any
Expand Down Expand Up @@ -509,13 +510,15 @@ def __hash__(self):
class PartitionType(Enum):
Boot = 'boot'
Primary = 'primary'
_Unknown = 'unknown'

@classmethod
def get_type_from_code(cls, code: int) -> PartitionType:
if code == parted.PARTITION_NORMAL:
return PartitionType.Primary

raise DiskError(f'Partition code not supported: {code}')
else:
info(f'Partition code not supported: {code}')
return PartitionType._Unknown

def get_partition_code(self) -> Optional[int]:
if self == PartitionType.Primary:
Expand Down Expand Up @@ -659,9 +662,9 @@ def from_existing_partition(cls, partition_info: _PartitionInfo) -> PartitionMod
if partition_info.btrfs_subvol_infos:
mountpoint = None
subvol_mods = []
for info in partition_info.btrfs_subvol_infos:
for i in partition_info.btrfs_subvol_infos:
subvol_mods.append(
SubvolumeModification.from_existing_subvol_info(info)
SubvolumeModification.from_existing_subvol_info(i)
)
else:
mountpoint = partition_info.mountpoints[0] if partition_info.mountpoints else None
Expand Down

0 comments on commit c8e0b9a

Please sign in to comment.