Skip to content

Commit c95a89c

Browse files
committed
devices: invalidate device cache on device-removed event
Avoid returning old device when it got removed already. This also (hopefully) fixes event handlers getting VirtualDevice instead of real one: Failed to handle event: sys-usb, device-added:usb, {'device': sys-usb+4-1:0bda:8179:00E04C0001:uffffff} Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/qubesadmin/events/__init__.py", line 278, in handle kwargs['device'] = plugged ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/qui/devices/device_widget.py", line 262, in device_added dev = backend.Device(device, self) File "/usr/lib/python3.13/site-packages/qui/devices/backend.py", line 156, in __init__ for interface in dev.interfaces: ^^^^^^^^^^^^^^ AttributeError: 'VirtualDevice' object has no attribute 'interfaces'
1 parent 9c733d8 commit c95a89c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

qubesadmin/events/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ def handle(self, subject, event, **kwargs):
257257
):
258258
devclass = event.split(":")[1]
259259
subject.devices[devclass]._attachment_cache = None
260+
elif event.split(":")[0] in ("device-removed",):
261+
devclass = event.split(":")[1]
262+
try:
263+
subject.devices[devclass]._dev_cache[kwargs["port"]]
264+
except KeyError:
265+
pass
260266

261267
# deserialize known attributes
262268
if event.startswith('device-'):

0 commit comments

Comments
 (0)