cleanup backup code (#753)
This commit is contained in:
parent
c68ac7db6d
commit
6db44dfab1
|
@ -474,6 +474,7 @@ public class LoginActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public void onWalletBackup(String walletName) {
|
public void onWalletBackup(String walletName) {
|
||||||
Timber.d("backup for wallet ." + walletName + ".");
|
Timber.d("backup for wallet ." + walletName + ".");
|
||||||
|
// overwrite any pending backup request
|
||||||
zipBackup = new ZipBackup(this, walletName);
|
zipBackup = new ZipBackup(this, walletName);
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
|
@ -500,14 +501,18 @@ public class LoginActivity extends BaseActivity
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
// nothing selected
|
// nothing selected
|
||||||
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
||||||
|
zipBackup = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (zipBackup == null) return; // ignore unsolicited request
|
||||||
zipBackup.writeTo(data.getData());
|
zipBackup.writeTo(data.getData());
|
||||||
Toast.makeText(this, getString(R.string.backup_success), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.backup_success), Toast.LENGTH_SHORT).show();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Timber.e(ex);
|
Timber.e(ex);
|
||||||
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
||||||
|
} finally {
|
||||||
|
zipBackup = null;
|
||||||
}
|
}
|
||||||
} else if (requestCode == RESTORE_BACKUP_INTENT) {
|
} else if (requestCode == RESTORE_BACKUP_INTENT) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
|
|
Loading…
Reference in New Issue