Heal tracking database if it can't open by JohnMcPMS · Pull Request #5724 · microsoft/winget-cli
Change
When we fail to open the tracking database, rename it and create a new one. The initial Open requires two things to succeed:
- SQLite considers this a valid database file
- The metadata table exists and contains a schema version that we can read
If an exception is thrown, we move the file (and the auxiliary journals if they exist) to new names (installed.db -> installed-corrupted.db) and create a new database.
Validation
Added a unit test that corrupts the database and is able to open the new one.