1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

refactor(core): move exclude list from wipe to wipe_cache

[no changelog]
This commit is contained in:
M1nd3r 2024-12-04 15:50:12 +01:00
parent 517707a1c2
commit e96b5e89ba
3 changed files with 18 additions and 10 deletions

View File

@ -58,7 +58,8 @@ async def recovery_process() -> Success:
if recovery_type == RecoveryType.NormalRecovery: if recovery_type == RecoveryType.NormalRecovery:
from trezor.wire.context import try_get_ctx_ids 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 raise wire.ActionCancelled

View File

@ -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 # start an empty progress screen so that the screen is not blank while waiting
render_empty_loader(config.StorageMessage.PROCESSING_MSG) render_empty_loader(config.StorageMessage.PROCESSING_MSG)
# wipe storage # 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 # erase translations
translations.deinit() translations.deinit()
translations.erase() translations.erase()

View File

@ -9,22 +9,23 @@ if TYPE_CHECKING:
pass 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. Wipes the storage.
If the device should communicate after wipe, use `exclude_protocol=True` and clear cache manually later using If the device should communicate after wipe, use `clear_cache=False` and clear cache manually later using
`wipe_cache()`. `wipe_cache()`.
""" """
from trezor import config from trezor import config
config.wipe() config.wipe()
if clear_cache:
cache.clear_all()
def wipe_cache(excluded: Tuple[bytes, bytes] | None = None) -> None:
cache.clear_all(excluded) cache.clear_all(excluded)
def wipe_cache() -> None:
cache.clear_all()
def init_unlocked() -> None: def init_unlocked() -> None:
# Check for storage version upgrade. # Check for storage version upgrade.
version = device.get_version() version = device.get_version()
@ -42,7 +43,8 @@ def reset(excluded: Tuple[bytes, bytes] | None) -> None:
Wipes storage but keeps the device id unchanged. Wipes storage but keeps the device id unchanged.
""" """
device_id = device.get_device_id() 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) common.set(common.APP_DEVICE, device.DEVICE_ID, device_id.encode(), public=True)