From cf88e520a03e3b6d8450171533c915c2b00da6f5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 4 Jun 2025 14:01:14 +0100 Subject: [PATCH] Fix restart loop in safeStorage if we started using a backend but it's now unusable, we need to prompt the user that we can't migrate: if the override flag is already set then we'll just restart in a loop. --- src/store.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store.ts b/src/store.ts index 357e479636..409b33a2f7 100644 --- a/src/store.ts +++ b/src/store.ts @@ -305,9 +305,14 @@ class Store extends ElectronStore { // Store the backend used for the safeStorage data so we can detect if it changes, and we know how the data is encoded this.recordSafeStorageBackend(backend); } else if (existingSafeStorageBackend !== backend) { + // We already appear to have started using a backend other than the one that we picked, so + // set the override flag and relaunch with the backend we were previously using, unless we + // already have the override flag, in which case we must assume the previous backend is no + // longer usable, in which case we should fall into the next block and warn the user we can't + // migrate. console.warn(`safeStorage backend changed from ${existingSafeStorageBackend} to ${backend}`); - if (existingSafeStorageBackend in safeStorageBackendMap) { + if (existingSafeStorageBackend in safeStorageBackendMap && !this.get("safeStorageBackendOverride")) { this.set("safeStorageBackendOverride", true); return relaunchApp(); } else {