1
0

GODT-1978: Auto-updates

This commit is contained in:
James Houlahan
2022-11-01 21:44:09 +01:00
parent 1e29a5210f
commit d093488522
16 changed files with 299 additions and 184 deletions

View File

@ -337,7 +337,17 @@ func (f *frontendCLI) watchEvents(eventCh <-chan events.Event) { // nolint:funle
)
case events.UpdateAvailable:
f.Printf("An update is available (version %v)\n", event.Version.Version)
if !event.Compatible {
f.Printf("A new version (%v) is available but it cannot be installed automatically.\n", event.Version.Version)
} else if !event.Silent {
f.Printf("A new version (%v) is available.\n", event.Version.Version)
}
case events.UpdateInstalled:
f.Printf("A new version (%v) was installed.\n", event.Version.Version)
case events.UpdateFailed:
f.Printf("A new version (%v) failed to be installed (%v).\n", event.Version.Version, event.Error)
case events.UpdateForced:
f.notifyNeedUpgrade()

View File

@ -18,12 +18,24 @@
package cli
import (
"github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/abiosoft/ishell"
)
func (f *frontendCLI) checkUpdates(c *ishell.Context) {
updateCh, done := f.bridge.GetEvents(events.UpdateAvailable{}, events.UpdateNotAvailable{})
defer done()
f.bridge.CheckForUpdates()
switch (<-updateCh).(type) {
case events.UpdateAvailable:
// ... this is handled by the main event loop
case events.UpdateNotAvailable:
f.Println("Bridge is already up to date.")
}
}
func (f *frontendCLI) enableAutoUpdates(c *ishell.Context) {