mirror of
https://github.com/beemdevelopment/Aegis
synced 2024-10-01 13:33:37 +00:00
Save the vault when saving group filter right after a vault version bump
This commit is contained in:
parent
892116fcd7
commit
2b69dc3a84
|
@ -1047,6 +1047,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
@Override
|
||||
public void onSaveGroupFilter(Set<UUID> groupFilter) {
|
||||
if (_vaultManager.getVault().isGroupsMigrationFresh()) {
|
||||
saveAndBackupVault();
|
||||
}
|
||||
_prefs.setGroupFilter(groupFilter);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ public class Vault {
|
|||
private final UUIDMap<VaultEntry> _entries = new UUIDMap<>();
|
||||
private final UUIDMap<VaultGroup> _groups = new UUIDMap<>();
|
||||
|
||||
// Whether we've migrated the group list to the new format while parsing the vault
|
||||
private boolean _isGroupsMigrationFresh = false;
|
||||
|
||||
public JSONObject toJson() {
|
||||
return toJson(null);
|
||||
}
|
||||
|
@ -70,7 +73,9 @@ public class Vault {
|
|||
JSONArray array = obj.getJSONArray("entries");
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
VaultEntry entry = VaultEntry.fromJson(array.getJSONObject(i));
|
||||
vault.migrateOldGroup(entry);
|
||||
if (vault.migrateOldGroup(entry)) {
|
||||
vault.setGroupsMigrationFresh();
|
||||
}
|
||||
|
||||
// check the vault has a group corresponding to each one the entry claims to be in
|
||||
for (UUID groupUuid: entry.getGroups()) {
|
||||
|
@ -88,7 +93,15 @@ public class Vault {
|
|||
return vault;
|
||||
}
|
||||
|
||||
public void migrateOldGroup(VaultEntry entry) {
|
||||
private void setGroupsMigrationFresh() {
|
||||
_isGroupsMigrationFresh = true;
|
||||
}
|
||||
|
||||
public boolean isGroupsMigrationFresh() {
|
||||
return _isGroupsMigrationFresh;
|
||||
}
|
||||
|
||||
public boolean migrateOldGroup(VaultEntry entry) {
|
||||
if (entry.getOldGroup() != null) {
|
||||
Optional<VaultGroup> optGroup = getGroups().getValues()
|
||||
.stream()
|
||||
|
@ -104,7 +117,10 @@ public class Vault {
|
|||
}
|
||||
|
||||
entry.setOldGroup(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public UUIDMap<VaultEntry> getEntries() {
|
||||
|
|
|
@ -314,6 +314,10 @@ public class VaultRepository {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public boolean isGroupsMigrationFresh() {
|
||||
return _vault.isGroupsMigrationFresh();
|
||||
}
|
||||
|
||||
public VaultFileCredentials getCredentials() {
|
||||
return _creds == null ? null : _creds.clone();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue