Skip to content

Commit

Permalink
Remove all OTP related data when embedded OTP database is deleted
Browse files Browse the repository at this point in the history
Properly flag main db as changed

Closes #137
  • Loading branch information
Rookiestyle committed May 6, 2023
1 parent 3ebc0a1 commit a7d30a8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/DAO/OTPDAO_DB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ public void OTPDB_Remove()
OTPDB = null;
Valid = OTPDB_Opened = OTPDB_Exists = false;
DB.CustomData.Remove(DBNAME);
DB.CustomData.Remove(Config.DBKeySources);
var lEntries = DB.RootGroup.GetEntries(true).Where(x => x.CustomData.Exists(DBNAME)).ToArray();
for (var i = 0; i < lEntries.Length; i ++)
{
lEntries[i].CreateBackup(DB);
lEntries[i].CustomData.Remove(DBNAME);
lEntries[i].Touch(true, false);
}
FlagChanged(false);
}

private PwDatabase OTPDB_Load()
Expand Down Expand Up @@ -189,6 +198,7 @@ private PwDatabase OTPDB_Load()
if (!KeySources_Equal(aka_old, aka_new)) KeySources_Save(aka_new);
KeySources_Clear();
OTPDAO.InitEntries(DB);
KPOTP.GetTimingsAsync(OTPDB); //For time correction
UpdateDBHeader();
if (OTPDB_Opened && CheckAndMigrate(DB))
FlagChanged(false);
Expand Down

0 comments on commit a7d30a8

Please sign in to comment.