mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix: do not overwrite monero backup files if they exist. (#2202)
This commit is contained in:
parent
990feb48ec
commit
5f4dc95ca5
1 changed files with 9 additions and 5 deletions
|
@ -19,15 +19,15 @@ Future<void> backupWalletFiles(String name) async {
|
||||||
final newKeysFilePath = backupFileName(keysFile.path);
|
final newKeysFilePath = backupFileName(keysFile.path);
|
||||||
final newAddressListFilePath = backupFileName(addressListFile.path);
|
final newAddressListFilePath = backupFileName(addressListFile.path);
|
||||||
|
|
||||||
if (cacheFile.existsSync()) {
|
if (cacheFile.existsSync() && !File(newCacheFilePath).existsSync()) {
|
||||||
await cacheFile.copy(newCacheFilePath);
|
await cacheFile.copy(newCacheFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keysFile.existsSync()) {
|
if (keysFile.existsSync() && !File(newKeysFilePath).existsSync()) {
|
||||||
await keysFile.copy(newKeysFilePath);
|
await keysFile.copy(newKeysFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addressListFile.existsSync()) {
|
if (addressListFile.existsSync() && !File(newAddressListFilePath).existsSync()) {
|
||||||
await addressListFile.copy(newAddressListFilePath);
|
await addressListFile.copy(newAddressListFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,13 @@ Future<bool> backupWalletFilesExists(String name) async {
|
||||||
Future<void> removeCache(String name) async {
|
Future<void> removeCache(String name) async {
|
||||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||||
final cacheFile = File(path);
|
final cacheFile = File(path);
|
||||||
|
final backgroundCacheFile = File(path + ".background");
|
||||||
if (cacheFile.existsSync()) {
|
if (cacheFile.existsSync()) {
|
||||||
cacheFile.deleteSync();
|
cacheFile.deleteSync();
|
||||||
}
|
}
|
||||||
|
if (backgroundCacheFile.existsSync()) {
|
||||||
|
backgroundCacheFile.deleteSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> restoreOrResetWalletFiles(String name) async {
|
Future<void> restoreOrResetWalletFiles(String name) async {
|
||||||
|
@ -94,7 +97,8 @@ Future<void> restoreOrResetWalletFiles(String name) async {
|
||||||
|
|
||||||
if (backupsExists) {
|
if (backupsExists) {
|
||||||
await removeCache(name);
|
await removeCache(name);
|
||||||
|
// TODO(mrcyjanek): is this needed?
|
||||||
|
// If we remove cache then wallet should be restored from .keys file.
|
||||||
await restoreWalletFiles(name);
|
await restoreWalletFiles(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue