diff --git a/core/src/apps/management/recovery_device/homescreen.py b/core/src/apps/management/recovery_device/homescreen.py index 3a3c1380d2..5b69e515bd 100644 --- a/core/src/apps/management/recovery_device/homescreen.py +++ b/core/src/apps/management/recovery_device/homescreen.py @@ -58,7 +58,8 @@ async def recovery_process() -> Success: if recovery_type == RecoveryType.NormalRecovery: from trezor.wire.context import try_get_ctx_ids - storage.wipe(excluded=try_get_ctx_ids()) + storage.wipe(clear_cache=False) + storage.wipe_cache(excluded=try_get_ctx_ids()) raise wire.ActionCancelled diff --git a/core/src/apps/management/wipe_device.py b/core/src/apps/management/wipe_device.py index 1abdc3f3e6..5a08bf1b18 100644 --- a/core/src/apps/management/wipe_device.py +++ b/core/src/apps/management/wipe_device.py @@ -38,8 +38,13 @@ async def wipe_device(msg: WipeDevice) -> NoReturn: # start an empty progress screen so that the screen is not blank while waiting render_empty_loader(config.StorageMessage.PROCESSING_MSG) + # wipe storage - storage.wipe(excluded=try_get_ctx_ids()) + storage.wipe(clear_cache=False) + + # clear cache - exclude current context + storage.wipe_cache(excluded=try_get_ctx_ids()) + # erase translations translations.deinit() translations.erase() diff --git a/core/src/storage/__init__.py b/core/src/storage/__init__.py index 2fe2c845d9..1253249090 100644 --- a/core/src/storage/__init__.py +++ b/core/src/storage/__init__.py @@ -9,22 +9,23 @@ if TYPE_CHECKING: pass -def wipe(excluded: Tuple[bytes, bytes] | None) -> None: +def wipe(clear_cache: bool = True) -> None: """ - TODO REPHRASE SO THAT IT IS TRUE! Wipes the storage. Using `exclude_protocol=False` destroys the THP communication channel. - If the device should communicate after wipe, use `exclude_protocol=True` and clear cache manually later using + Wipes the storage. + If the device should communicate after wipe, use `clear_cache=False` and clear cache manually later using `wipe_cache()`. """ from trezor import config config.wipe() + if clear_cache: + cache.clear_all() + + +def wipe_cache(excluded: Tuple[bytes, bytes] | None = None) -> None: cache.clear_all(excluded) -def wipe_cache() -> None: - cache.clear_all() - - def init_unlocked() -> None: # Check for storage version upgrade. version = device.get_version() @@ -42,7 +43,8 @@ def reset(excluded: Tuple[bytes, bytes] | None) -> None: Wipes storage but keeps the device id unchanged. """ device_id = device.get_device_id() - wipe(excluded) + wipe(clear_cache=False) + wipe_cache(excluded) common.set(common.APP_DEVICE, device.DEVICE_ID, device_id.encode(), public=True)