mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 02:01:36 +03:00
Desktop: Improve DeviceInfo caching
This commit is contained in:
parent
848605c855
commit
a35875a51e
@ -274,9 +274,6 @@ class AbstractDeviceNode(RpcNode):
|
||||
# Clear DeviceInfo cache
|
||||
self._info = None
|
||||
self._data = None
|
||||
# Make sure any child node is re-opened after this,
|
||||
# as enabled applications may have changed
|
||||
super().close()
|
||||
|
||||
return response
|
||||
|
||||
@ -465,7 +462,20 @@ class ConnectionNode(RpcNode):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
try:
|
||||
return super().__call__(*args, **kwargs)
|
||||
response = super().__call__(*args, **kwargs)
|
||||
if "device_info" in response.flags:
|
||||
# Refresh DeviceInfo
|
||||
info = read_info(self._connection, self._device.pid)
|
||||
if self._info != info:
|
||||
self._info = info
|
||||
# Make sure any child node is re-opened after this,
|
||||
# as enabled applications may have changed
|
||||
self.close()
|
||||
else:
|
||||
# No change to DeviceInfo, further propagation not needed.
|
||||
response.flags.remove("device_info")
|
||||
|
||||
return response
|
||||
except (SmartcardException, OSError) as e:
|
||||
logger.exception("Connection error")
|
||||
raise ChildResetException(f"{e}")
|
||||
|
@ -502,7 +502,7 @@ class SlotNode(RpcNode):
|
||||
|
||||
self._refresh()
|
||||
|
||||
return dict(
|
||||
response = dict(
|
||||
metadata=_metadata_dict(metadata),
|
||||
public_key=(
|
||||
private_key.public_key()
|
||||
@ -519,6 +519,7 @@ class SlotNode(RpcNode):
|
||||
else None
|
||||
),
|
||||
)
|
||||
return RpcResponse(response, ["device_info"])
|
||||
|
||||
@action
|
||||
def generate(self, params, event, signal):
|
||||
@ -570,4 +571,5 @@ class SlotNode(RpcNode):
|
||||
|
||||
self._refresh()
|
||||
|
||||
return dict(public_key=public_key_pem, result=result)
|
||||
response = dict(public_key=public_key_pem, result=result)
|
||||
return RpcResponse(response, ["device_info"])
|
||||
|
Loading…
Reference in New Issue
Block a user