Skip to content

Commit 52f6f6c

Browse files
authored
Merge branch 'Hog185:dev' into dev
2 parents 85a54c1 + 95680bb commit 52f6f6c

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

src/lufus/drives/find_usb.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,24 @@ def find_usb() -> dict[str, str]:
4848
continue
4949
mount_path = part.mountpoint
5050
device_node = part.device
51-
if device_node:
52-
try:
53-
label = subprocess.check_output(
54-
["lsblk", "-d", "-n", "-o", "LABEL", device_node],
55-
text=True,
56-
timeout=5,
57-
).strip()
58-
if not label:
59-
label = os.path.basename(mount_path)
60-
usbdict[mount_path] = label
61-
log.info("Found USB: %s -> %s", mount_path, label)
62-
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
63-
label = os.path.basename(mount_path)
64-
usbdict[mount_path] = label
65-
log.info("Found USB: %s -> %s", mount_path, label)
51+
if not device_node:
52+
continue
53+
54+
label = None
55+
try:
56+
label = subprocess.check_output(
57+
["lsblk", "-d", "-n", "-o", "LABEL", device_node],
58+
text=True,
59+
timeout=5,
60+
).strip()
61+
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
62+
pass
63+
64+
if not label:
65+
label = os.path.basename(mount_path)
66+
67+
usbdict[mount_path] = label
68+
log.info("Found USB: %s -> %s", mount_path, label)
6669

6770
return usbdict
6871

0 commit comments

Comments
 (0)