From 5789a86b2bdfeb9c163b229f94b7add95ad683e4 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 3 Feb 2021 16:30:23 +0100 Subject: [PATCH] fix: Unlock the mutex --- lib/utils/famedlysdk_store.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/utils/famedlysdk_store.dart b/lib/utils/famedlysdk_store.dart index 53d771e1..c6fd88ed 100644 --- a/lib/utils/famedlysdk_store.dart +++ b/lib/utils/famedlysdk_store.dart @@ -94,6 +94,8 @@ class Store { return await secureStorage.read(key: key); } catch (_) { return null; + } finally { + _mutex.unlock(); } } @@ -111,8 +113,12 @@ class Store { await _setupLocalStorage(); return await storage.setItem(key, value); } - await _mutex.lock(); - return await secureStorage.write(key: key, value: value); + try { + await _mutex.lock(); + return await secureStorage.write(key: key, value: value); + } finally { + _mutex.unlock(); + } } Future setItemBool(String key, bool value) async { @@ -124,7 +130,11 @@ class Store { await _setupLocalStorage(); return await storage.deleteItem(key); } - await _mutex.lock(); - return await secureStorage.delete(key: key); + try { + await _mutex.lock(); + return await secureStorage.delete(key: key); + } finally { + _mutex.unlock(); + } } }