Skip to content

Commit

Permalink
Prevent from crashing due to missing check
Browse files Browse the repository at this point in the history
  • Loading branch information
0140454 committed Apr 21, 2018
1 parent 50c99dc commit e321ae9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,17 @@ protected Boolean doInBackground(String... params) {
if (params.length != 2) return false;
File walletFile = Helper.getWalletFile(LoginActivity.this, params[0]);
String newName = params[1];
return renameWallet(walletFile, newName);
boolean success = renameWallet(walletFile, newName);
try {
if (success && FingerprintHelper.isFingerprintAuthAllowed(params[0])) {
String savedPass = KeyStoreHelper.loadWalletUserPass(LoginActivity.this, params[0]);
KeyStoreHelper.saveWalletUserPass(LoginActivity.this, newName, savedPass);
KeyStoreHelper.removeWalletUserPass(LoginActivity.this, params[0]);
}
} catch (KeyStoreException ex) {
ex.printStackTrace();
}
return success;
}

@Override
Expand All @@ -259,9 +269,6 @@ protected void onPostExecute(Boolean result) {
// copy + delete seems safer than rename because we call rollback easily
boolean renameWallet(File walletFile, String newName) {
if (copyWallet(walletFile, new File(walletFile.getParentFile(), newName), false, true)) {
String savedPass = KeyStoreHelper.loadWalletUserPass(LoginActivity.this, walletFile.getName());
KeyStoreHelper.saveWalletUserPass(LoginActivity.this, newName, savedPass);
KeyStoreHelper.removeWalletUserPass(LoginActivity.this, walletFile.getName());
deleteWallet(walletFile);
return true;
} else {
Expand Down

0 comments on commit e321ae9

Please sign in to comment.