Move get_unique_path_for_device() to disk.utils (#4242)
This commit is contained in:
parent
083a73eab1
commit
8edab9fafd
|
|
@ -191,19 +191,6 @@ class DeviceHandler:
|
|||
lsblk = get_lsblk_info(dev_path)
|
||||
return Path(f'/dev/{lsblk.pkname}')
|
||||
|
||||
def get_unique_path_for_device(self, dev_path: Path) -> Path | None:
|
||||
paths = Path('/dev/disk/by-id').glob('*')
|
||||
linked_targets = {p.resolve(): p for p in paths}
|
||||
linked_wwn_targets = {p: linked_targets[p] for p in linked_targets if p.name.startswith('wwn-') or p.name.startswith('nvme-eui.')}
|
||||
|
||||
if dev_path in linked_wwn_targets:
|
||||
return linked_wwn_targets[dev_path]
|
||||
|
||||
if dev_path in linked_targets:
|
||||
return linked_targets[dev_path]
|
||||
|
||||
return None
|
||||
|
||||
def get_uuid_for_path(self, path: Path) -> str | None:
|
||||
partition = self.find_partition(path)
|
||||
return partition.partuuid if partition else None
|
||||
|
|
|
|||
|
|
@ -110,6 +110,20 @@ def disk_layouts() -> str:
|
|||
return lsblk_output.model_dump_json(indent=4)
|
||||
|
||||
|
||||
def get_unique_path_for_device(dev_path: Path) -> Path | None:
|
||||
paths = Path('/dev/disk/by-id').glob('*')
|
||||
linked_targets = {p.resolve(): p for p in paths}
|
||||
linked_wwn_targets = {p: linked_targets[p] for p in linked_targets if p.name.startswith('wwn-') or p.name.startswith('nvme-eui.')}
|
||||
|
||||
if dev_path in linked_wwn_targets:
|
||||
return linked_wwn_targets[dev_path]
|
||||
|
||||
if dev_path in linked_targets:
|
||||
return linked_targets[dev_path]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def mount(
|
||||
dev_path: Path,
|
||||
target_mountpoint: Path,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@ from typing import Any, Self
|
|||
|
||||
from archinstall.lib.disk.device_handler import device_handler
|
||||
from archinstall.lib.disk.fido import Fido2
|
||||
from archinstall.lib.disk.utils import get_lsblk_by_mountpoint, get_lsblk_info, mount, swapon
|
||||
from archinstall.lib.disk.utils import (
|
||||
get_lsblk_by_mountpoint,
|
||||
get_lsblk_info,
|
||||
get_unique_path_for_device,
|
||||
mount,
|
||||
swapon,
|
||||
)
|
||||
from archinstall.lib.models.application import ZramAlgorithm
|
||||
from archinstall.lib.models.device import (
|
||||
DiskEncryption,
|
||||
|
|
@ -1534,7 +1540,7 @@ class Installer:
|
|||
|
||||
parent_dev_path = device_handler.get_parent_device_path(boot_partition.safe_dev_path)
|
||||
|
||||
if unique_path := device_handler.get_unique_path_for_device(parent_dev_path):
|
||||
if unique_path := get_unique_path_for_device(parent_dev_path):
|
||||
parent_dev_path = unique_path
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue