Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
Daniel Girtler 2023-05-07 16:39:25 +10:00 committed by GitHub
parent eb23b2d7c9
commit 525c94bf36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -10,7 +10,7 @@ from typing import List, Dict, Any, Optional, TYPE_CHECKING
from parted import ( # type: ignore
Disk, Geometry, FileSystem,
PartitionException, DiskLabelException,
getAllDevices, freshDisk, Partition,
getAllDevices, freshDisk, Partition, Device
)
from .device_model import (
@ -103,7 +103,8 @@ class DeviceHandler(object):
def get_device_by_partition_path(self, partition_path: Path) -> Optional[BDevice]:
partition = self.find_partition(partition_path)
if partition:
return partition.disk.device
device: Device = partition.disk.device
return self.get_device(Path(device.path))
return None
def find_partition(self, path: Path) -> Optional[_PartitionInfo]: