diff --git a/helper/helper/device.py b/helper/helper/device.py index 34f44e3f..a2db4192 100644 --- a/helper/helper/device.py +++ b/helper/helper/device.py @@ -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}") diff --git a/helper/helper/piv.py b/helper/helper/piv.py index f1b9c198..7045343b 100644 --- a/helper/helper/piv.py +++ b/helper/helper/piv.py @@ -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"])