mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
GODT-1537: Manual in-app update mechanism.
This commit is contained in:
@ -153,7 +153,7 @@ func (f *FrontendQt) NotifySilentUpdateInstalled() {
|
||||
}
|
||||
|
||||
func (f *FrontendQt) NotifySilentUpdateError(err error) {
|
||||
f.log.WithError(err).Warn("Update failed, asking for manual.")
|
||||
f.log.WithError(err).Warn("In-app update failed, asking for manual.")
|
||||
f.qml.UpdateManualError()
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/config/settings"
|
||||
"github.com/ProtonMail/proton-bridge/internal/updater"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var checkingUpdates = sync.Mutex{}
|
||||
@ -62,9 +63,18 @@ func (f *FrontendQt) checkUpdatesAndNotify(isRequestFromUser bool) {
|
||||
|
||||
if !f.updater.CanInstall(f.newVersionInfo) {
|
||||
f.log.Debug("A manual update is required")
|
||||
f.qml.UpdateManualReady(f.newVersionInfo.Version.String())
|
||||
f.qml.UpdateManualError()
|
||||
return
|
||||
}
|
||||
|
||||
if f.settings.GetBool(settings.AutoUpdateKey) {
|
||||
// NOOP will update eventually
|
||||
return
|
||||
}
|
||||
|
||||
if isRequestFromUser {
|
||||
f.qml.UpdateManualReady(f.newVersionInfo.Version.String())
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FrontendQt) updateForce() {
|
||||
@ -113,3 +123,26 @@ func (f *FrontendQt) toggleBeta(makeItEnabled bool) {
|
||||
// Immediately check the updates to set the correct landing page link.
|
||||
f.checkUpdates()
|
||||
}
|
||||
|
||||
func (f *FrontendQt) installUpdate() {
|
||||
checkingUpdates.Lock()
|
||||
defer checkingUpdates.Unlock()
|
||||
|
||||
if !f.updater.CanInstall(f.newVersionInfo) {
|
||||
f.log.Warning("Skipping update installation, current version too old")
|
||||
f.qml.UpdateManualError()
|
||||
return
|
||||
}
|
||||
|
||||
if err := f.updater.InstallUpdate(f.newVersionInfo); err != nil {
|
||||
if errors.Cause(err) == updater.ErrDownloadVerify {
|
||||
f.log.WithError(err).Warning("Skipping update installation due to temporary error")
|
||||
} else {
|
||||
f.log.WithError(err).Error("The update couldn't be installed")
|
||||
f.qml.UpdateManualError()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
f.qml.UpdateSilentRestartNeeded()
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ type QMLBackend struct {
|
||||
_ func() `signal:"updateIsLatestVersion"`
|
||||
_ func() `slot:"checkUpdates"`
|
||||
_ func() `signal:"checkUpdatesFinished"`
|
||||
_ func() `slot:"installUpdate"`
|
||||
|
||||
_ bool `property:"isDiskCacheEnabled"`
|
||||
_ core.QUrl `property:"diskCachePath"`
|
||||
@ -213,6 +214,13 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
||||
}()
|
||||
})
|
||||
|
||||
q.ConnectInstallUpdate(func() {
|
||||
go func() {
|
||||
defer f.panicHandler.HandlePanic()
|
||||
f.installUpdate()
|
||||
}()
|
||||
})
|
||||
|
||||
f.setIsDiskCacheEnabled()
|
||||
f.setDiskCachePath()
|
||||
q.ConnectChangeLocalCache(func(e bool, d *core.QUrl) {
|
||||
|
||||
Reference in New Issue
Block a user