Prevent a crash caused by adding the same entry to the vault twice

This could happen in rare cases where writing the vault to disk failed.
This commit is contained in:
Alexander Bakker 2020-08-15 18:32:14 +02:00
parent 7d38bc9b71
commit d43e5e04c7

View file

@ -452,7 +452,11 @@ public class EditEntryActivity extends AegisActivity {
}
private void addAndFinish(VaultEntry entry) {
if (_isNew) {
// It's possible that the new entry was already added to the vault, but writing the
// vault to disk failed, causing the user to tap 'Save' again. Calling addEntry
// again would cause a crash in that case, so the isEntryDuplicate check prevents
// that.
if (_isNew && !_vault.isEntryDuplicate(entry)) {
_vault.addEntry(entry);
} else {
_vault.replaceEntry(entry);