Repository navigation
feat(updater): back up local data before an update, refuse a newer schema untouched, explain the channel row on package installs (#1497) - #1710
Merged
Conversation
…fuse a newer schema without changing it, explain the channel row on package installs (#1497)
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1497. Part of the Beta channel epic #1499.
A beta can carry a newer local database schema than the stable it is promoted to, and nothing protected the user from that, or told a package-manager user that the channel setting does nothing for them.
Backup before an in-app update
UpdateBackup(lib/core/storage/update_backup.dart) copiesquerya.dband its-waltoquerya.db.pre-<from>-<to>.bak, keeps the newest 3 (a copy's-walgoes with it) and deletes older ones. Versions are sanitised in the name.LocalDb.backupBeforeUpdatecloses the database, makes the copy and leaves reopening to the next query.Newer-schema guard
LocalDbpassesonDowngradeand throwsLocalDbNewerSchemaException(found, supported, path). The throw happens inside sqflite's open transaction, so it rolls back and the file keeps its version number; without it sqflite stamps the older number on the file and the build carries on with tables it does not know. The recovery screen already prints the error; the message names the newer data format and the.bakto restore.Release channel row (Preferences → General)
.debor.rpminstall (UpdateInstallContext.isPackageManagerInstall) the dropdown is disabled, shows Stable and the hint says updates come from the package manager (stable only).AppUpdaterService.checkForUpdatesreadsreleases/latestthere whatever the stored channel is, so such an install is not told about a beta it cannot install.Docs:
docs/user-guide.md("Updates, betas and going back": channels, the pre-update copy, how to go back by restoring it) anddocs/security.md(schema version and the guard).Not done: a stored "schema version" separate from sqflite's
user_version(it already is the schema version:_dbVersion = 13); a button in the recovery screen that restores the newest.bak(the file name is in the message and the user guide describes the manual steps).Tests: backup naming, WAL copy and removal of a stale WAL copy, keeping the newest three with their WALs, a missing database;
LocalDbbackup then reopen; a database set to a neweruser_versionis refused with the right numbers and its version is still the newer one afterwards; the channel row on a portable and on a package install; a package install readingreleases/latestwhile the stored channel is Beta; the update dialog copies before installing, asks when the copy fails, and honours Cancel and Install without a copy.