mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
open wallet even when cache file backup is corrupted
This commit is contained in:
parent
f8b0c0ad2a
commit
b169422a3c
1 changed files with 16 additions and 6 deletions
|
@ -55,6 +55,12 @@ class MoneroRestoreWalletFromKeysCredentials extends WalletCredentials {
|
|||
final String spendKey;
|
||||
}
|
||||
|
||||
enum OpenWalletTry {
|
||||
initial,
|
||||
cacheRestored,
|
||||
cacheRemoved,
|
||||
}
|
||||
|
||||
class MoneroWalletService extends WalletService<
|
||||
MoneroNewWalletCredentials,
|
||||
MoneroRestoreWalletFromSeedCredentials,
|
||||
|
@ -117,7 +123,7 @@ class MoneroWalletService extends WalletService<
|
|||
}
|
||||
|
||||
@override
|
||||
Future<MoneroWallet> openWallet(String name, String password, {bool? retryOnFailure}) async {
|
||||
Future<MoneroWallet> openWallet(String name, String password, {OpenWalletTry openWalletTry = OpenWalletTry.initial}) async {
|
||||
try {
|
||||
final path = await pathForWallet(name: name, type: getType());
|
||||
|
||||
|
@ -147,12 +153,16 @@ class MoneroWalletService extends WalletService<
|
|||
} catch (e) {
|
||||
// TODO: Implement Exception for wallet list service.
|
||||
|
||||
if (retryOnFailure == false) {
|
||||
rethrow;
|
||||
switch (openWalletTry) {
|
||||
case OpenWalletTry.initial:
|
||||
await restoreOrResetWalletFiles(name);
|
||||
return openWallet(name, password, openWalletTry: OpenWalletTry.cacheRestored);
|
||||
case OpenWalletTry.cacheRestored:
|
||||
await removeCache(name);
|
||||
return openWallet(name, password, openWalletTry: OpenWalletTry.cacheRemoved);
|
||||
case OpenWalletTry.cacheRemoved:
|
||||
rethrow;
|
||||
}
|
||||
|
||||
await restoreOrResetWalletFiles(name);
|
||||
return openWallet(name, password, retryOnFailure: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue