Merge branch 'soru/fix-mutex' into 'main'

fix: Unlock the mutex

See merge request famedly/fluffychat!370
This commit is contained in:
Krille Fear 2021-02-03 15:48:56 +00:00
commit 6348953fb8

View File

@ -94,6 +94,8 @@ class Store {
return await secureStorage.read(key: key); return await secureStorage.read(key: key);
} catch (_) { } catch (_) {
return null; return null;
} finally {
_mutex.unlock();
} }
} }
@ -111,8 +113,12 @@ class Store {
await _setupLocalStorage(); await _setupLocalStorage();
return await storage.setItem(key, value); return await storage.setItem(key, value);
} }
try {
await _mutex.lock(); await _mutex.lock();
return await secureStorage.write(key: key, value: value); return await secureStorage.write(key: key, value: value);
} finally {
_mutex.unlock();
}
} }
Future<void> setItemBool(String key, bool value) async { Future<void> setItemBool(String key, bool value) async {
@ -124,7 +130,11 @@ class Store {
await _setupLocalStorage(); await _setupLocalStorage();
return await storage.deleteItem(key); return await storage.deleteItem(key);
} }
try {
await _mutex.lock(); await _mutex.lock();
return await secureStorage.delete(key: key); return await secureStorage.delete(key: key);
} finally {
_mutex.unlock();
}
} }
} }