Remove old config copies from updates
Settings -> Upkeep -> Backup & restore lists the config.json.bak-* files that update leaves behind and removes one or all of them; they hold the same secrets as a backup. Removing needs a signed-in user and is logged. After a successful update only the newest 3 copies are kept, and a copy that would overwrite an older one (version unknown, or the same version twice) gets the time appended. The backup card now also names preshared keys and authenticator app secrets. The update notice uses the existing compareVersions instead of its own.
This commit is contained in:
@@ -589,7 +589,7 @@ func cmdUpdate(args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
backup := configFile + ".bak-" + oldVersion
|
||||
backup := newUpdateBackupPath(configFile, oldVersion, time.Now())
|
||||
step("Backing up config to %s", backup)
|
||||
if err := copyFile(configFile, backup, 0o600, uid, gid); err != nil {
|
||||
return err
|
||||
@@ -627,6 +627,11 @@ func cmdUpdate(args []string) error {
|
||||
}
|
||||
return fmt.Errorf("update failed, %s %s is running again: %w", appName, oldVersion, err)
|
||||
}
|
||||
if n, err := pruneUpdateBackups(configFile, keepUpdateBackups); err != nil {
|
||||
fmt.Fprintln(os.Stderr, " Could not remove older config backups:", err)
|
||||
} else if n > 0 {
|
||||
step("Removed %d older config backups, kept the newest %d", n, keepUpdateBackups)
|
||||
}
|
||||
fmt.Printf("\nUpdated %s %s → %s.\n", appName, oldVersion, version)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user