Add udev_sync() (#2669)

This commit is contained in:
codefiles 2024-09-06 17:29:12 -04:00 committed by GitHub
parent 7c08822d08
commit 6a2a204f18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -47,7 +47,7 @@ class DeviceHandler(object):
def load_devices(self) -> None: def load_devices(self) -> None:
block_devices = {} block_devices = {}
SysCommand('udevadm settle') self.udev_sync()
all_lsblk_info = get_all_lsblk_info() all_lsblk_info = get_all_lsblk_info()
devices = getAllDevices() devices = getAllDevices()
@ -784,6 +784,13 @@ class DeviceHandler(object):
self._wipe(block_device.device_info.path) self._wipe(block_device.device_info.path)
@staticmethod
def udev_sync() -> None:
try:
SysCommand('udevadm settle')
except SysCallError as err:
debug(f'Failed to synchronize with udev: {err}')
device_handler = DeviceHandler() device_handler = DeviceHandler()

View File

@ -17,7 +17,6 @@ from ..hardware import SysInfo
from ..luks import Luks2 from ..luks import Luks2
from ..menu import Menu from ..menu import Menu
from ..output import debug, info from ..output import debug, info
from ..general import SysCommand
if TYPE_CHECKING: if TYPE_CHECKING:
_: Any _: Any
@ -114,7 +113,7 @@ class FilesystemHandler:
device_handler.format(part_mod.safe_fs_type, part_mod.safe_dev_path) device_handler.format(part_mod.safe_fs_type, part_mod.safe_dev_path)
# synchronize with udev before using lsblk # synchronize with udev before using lsblk
SysCommand('udevadm settle') device_handler.udev_sync()
lsblk_info = device_handler.fetch_part_info(part_mod.safe_dev_path) lsblk_info = device_handler.fetch_part_info(part_mod.safe_dev_path)