mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: confirm kvdb migration at startup
Prompt before automatically migrating legacy kvdb state to SQL when litd starts with a SQL backend and active bbolt data is still present. Detect prior migrations by checking for the SQL tombstone marker so already-migrated stores can start without prompting. Add unit coverage for the prompt flow and wire stdin through the itest harness so the migration restart path can acknowledge the prompt automatically.
This commit is contained in:
parent
f5046d1f4e
commit
9016bbb3d2
9 changed files with 449 additions and 0 deletions
|
|
@ -85,6 +85,31 @@ func CheckKVDBDeprecated(path string, bucketKey []byte,
|
|||
return nil
|
||||
}
|
||||
|
||||
// HasActiveKVDB reports whether the legacy bbolt database at the given path
|
||||
// exists and has not yet been tombstoned by a SQL migration in the specified
|
||||
// top-level bucket. A missing file or a tombstoned database is reported as
|
||||
// inactive, so callers can use this to detect kvdb state that is still pending
|
||||
// migration to SQL.
|
||||
func HasActiveKVDB(path string, bucketKey []byte,
|
||||
timeout time.Duration) (bool, error) {
|
||||
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
err := CheckKVDBDeprecated(path, bucketKey, timeout)
|
||||
switch {
|
||||
case errors.Is(err, ErrKVDBDeprecated):
|
||||
return false, nil
|
||||
|
||||
case err != nil:
|
||||
return false, err
|
||||
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// IsMigrationTombstoneKey returns true if the given key is the kvdb migration
|
||||
// tombstone marker.
|
||||
func IsMigrationTombstoneKey(key []byte) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue