Fix vdev parsing: use leading whitespace count instead of tab count
This commit is contained in:
@@ -59,11 +59,11 @@ async def get_zfs_pool_map() -> dict[str, dict]:
|
|||||||
if not in_config or not current_pool:
|
if not in_config or not current_pool:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Count leading tab depth to distinguish pool/vdev/device lines.
|
# Indentation: 1 tab = pool name, 1 tab + 2 spaces = vdev,
|
||||||
# Pool name = 1 tab, vdev = 2 tabs, device = 3+ tabs
|
# 1 tab + 4 spaces = device. Count chars before content.
|
||||||
tab_count = len(line) - len(line.lstrip('\t'))
|
leading = len(line) - len(line.lstrip())
|
||||||
|
|
||||||
if tab_count == 2 and "/dev/" not in stripped:
|
if "/dev/" not in stripped and leading == 3:
|
||||||
# This is a vdev line (mirror-0, raidz2-0, etc.)
|
# This is a vdev line (mirror-0, raidz2-0, etc.)
|
||||||
current_vdev = stripped.split()[0]
|
current_vdev = stripped.split()[0]
|
||||||
elif "/dev/" in stripped:
|
elif "/dev/" in stripped:
|
||||||
|
|||||||
Reference in New Issue
Block a user