cleanup backup code (#753)

This commit is contained in:
m2049r 2021-04-21 19:54:20 +02:00 committed by GitHub
parent c68ac7db6d
commit 6db44dfab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -474,6 +474,7 @@ public class LoginActivity extends BaseActivity
@Override
public void onWalletBackup(String walletName) {
Timber.d("backup for wallet ." + walletName + ".");
// overwrite any pending backup request
zipBackup = new ZipBackup(this, walletName);
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
@ -500,14 +501,18 @@ public class LoginActivity extends BaseActivity
if (data == null) {
// nothing selected
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
zipBackup = null;
return;
}
try {
if (zipBackup == null) return; // ignore unsolicited request
zipBackup.writeTo(data.getData());
Toast.makeText(this, getString(R.string.backup_success), Toast.LENGTH_SHORT).show();
} catch (IOException ex) {
Timber.e(ex);
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
} finally {
zipBackup = null;
}
} else if (requestCode == RESTORE_BACKUP_INTENT) {
if (data == null) {