mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 05:52:52 +00:00
Merge pull request #1391 from alexbakker/fix-1329
Save the vault when saving group filter right after a vault version bump
This commit is contained in:
commit
2864f9b30c
3 changed files with 25 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue