GODT-1670: restore update [skip-ci]

GODT-1670: Log the gRPC call
This commit is contained in:
Romain LE JEUNE
2022-07-25 10:03:54 +02:00
committed by Jakub
parent d3f9756bdb
commit 649364beb5
4 changed files with 47 additions and 8 deletions

View File

@ -305,7 +305,7 @@ void QMLBackend::toggleAutomaticUpdate(bool active)
//****************************************************************************************************************************************************
void QMLBackend::checkUpdates()
{
app().grpc().checkUpdate();
logGRPCCallStatus(app().grpc().checkUpdate(), "checkUpdate");
}
@ -314,7 +314,7 @@ void QMLBackend::checkUpdates()
//****************************************************************************************************************************************************
void QMLBackend::installUpdate()
{
app().log().error(QString("%1() is not implemented.").arg(__FUNCTION__));
logGRPCCallStatus(app().grpc().installUpdate(), "installUpdate");
}

View File

@ -33,7 +33,6 @@ void initQtApplication()
if ((!qsgInfo.isEmpty()) && (qsgInfo != "0"))
QLoggingCategory::setFilterRules("qt.scenegraph.general=true");
/// \todo GODT-1670 Get version from go backend.
QGuiApplication::setApplicationName("Proton Mail Bridge");
QGuiApplication::setApplicationVersion(PROJECT_VER);
QGuiApplication::setOrganizationName("Proton AG");

View File

@ -38,6 +38,7 @@ import (
"github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
"github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
@ -179,9 +180,17 @@ func (s *Service) NotifyManualUpdate(version updater.VersionInfo, canInstall boo
func (s *Service) SetVersion(update updater.VersionInfo) {
s.newVersionInfo = update
}
func (s *Service) NotifySilentUpdateInstalled() {}
func (s *Service) NotifySilentUpdateError(error) {}
func (s *Service) WaitUntilFrontendIsReady() {}
func (s *Service) NotifySilentUpdateInstalled() {
_ = s.SendEvent(NewUpdateSilentRestartNeededEvent())
}
func (s *Service) NotifySilentUpdateError(err error) {
s.log.WithError(err).Error("In app update failed, asking for manual.")
_ = s.SendEvent(NewUpdateErrorEvent(UpdateErrorType_UPDATE_SILENT_ERROR))
}
func (s *Service) WaitUntilFrontendIsReady() {}
func (s *Service) watchEvents() { // nolint:funlen
if s.bridge.HasError(bridge.ErrLocalCacheUnavailable) {
@ -336,7 +345,10 @@ func (s *Service) checkUpdate() {
}
func (s *Service) updateForce() {
s.log.Error("updateForce is not implemented") // TO-DO GODT-1670 implement update.
checkingUpdates.Lock()
defer checkingUpdates.Unlock()
s.checkUpdate()
_ = s.SendEvent(NewUpdateForceEvent(s.newVersionInfo.Version.String()))
}
func (s *Service) checkUpdateAndNotify(isReqFromUser bool) {
@ -363,3 +375,26 @@ func (s *Service) checkUpdateAndNotify(isReqFromUser bool) {
s.NotifyManualUpdate(s.newVersionInfo, s.updater.CanInstall(s.newVersionInfo))
}
}
func (s *Service) installUpdate() {
checkingUpdates.Lock()
defer checkingUpdates.Unlock()
if !s.updater.CanInstall(s.newVersionInfo) {
s.log.Warning("Skipping update installation, current version too old")
_ = s.SendEvent(NewUpdateErrorEvent(UpdateErrorType_UPDATE_MANUAL_ERROR))
return
}
if err := s.updater.InstallUpdate(s.newVersionInfo); err != nil {
if errors.Cause(err) == updater.ErrDownloadVerify {
s.log.WithError(err).Warning("Skipping update installation due to temporary error")
} else {
s.log.WithError(err).Error("The update couldn't be installed")
_ = s.SendEvent(NewUpdateErrorEvent(UpdateErrorType_UPDATE_MANUAL_ERROR))
}
return
}
_ = s.SendEvent(NewUpdateSilentRestartNeededEvent())
}

View File

@ -404,7 +404,12 @@ func (s *Service) CheckUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty,
func (s *Service) InstallUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) {
s.log.Info("InstallUpdate")
// TO-DO GODT-1670 Implement update install
go func() {
defer s.panicHandler.HandlePanic()
s.installUpdate()
}()
return &emptypb.Empty{}, nil
}