GODT-1047 No silent updates for Import-Export app

This commit is contained in:
Michal Horejsek
2021-03-10 18:56:55 +00:00
committed by Alexander Bilyak
parent 27541784aa
commit a0132e8440
7 changed files with 57 additions and 79 deletions

View File

@ -28,8 +28,6 @@ import (
"github.com/ProtonMail/proton-bridge/internal/frontend"
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/importexport"
"github.com/ProtonMail/proton-bridge/internal/updater"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -88,7 +86,7 @@ func run(b *base.Base, c *cli.Context) error {
return f.Loop()
}
func checkAndHandleUpdate(u types.Updater, f frontend.Frontend, autoUpdate bool) {
func checkAndHandleUpdate(u types.Updater, f frontend.Frontend, autoUpdate bool) { //nolint[unparam]
version, err := u.Check()
if err != nil {
logrus.WithError(err).Error("An error occurred while checking for updates")
@ -107,27 +105,5 @@ func checkAndHandleUpdate(u types.Updater, f frontend.Frontend, autoUpdate bool)
logrus.WithField("version", version.Version).Info("An update is available")
if !autoUpdate {
f.NotifyManualUpdate(version, u.CanInstall(version))
return
}
if !u.CanInstall(version) {
logrus.Info("A manual update is required")
f.NotifySilentUpdateError(updater.ErrManualUpdateRequired)
return
}
if err := u.InstallUpdate(version); err != nil {
if errors.Cause(err) == updater.ErrDownloadVerify {
logrus.WithError(err).Warning("Skipping update installation due to temporary error")
} else {
logrus.WithError(err).Error("The update couldn't be installed")
f.NotifySilentUpdateError(err)
}
return
}
f.NotifySilentUpdateInstalled()
f.NotifyManualUpdate(version, u.CanInstall(version))
}

View File

@ -215,7 +215,7 @@ Item {
}
go.updateState = "updateRestart"
winMain.dialogUpdate.finished(false)
// after manual update - just retart immidiatly
go.setToRestart()
Qt.quit()
@ -236,13 +236,13 @@ Item {
}
}
onNotifySilentUpdateRestartNeeded: {
go.updateState = "updateRestart"
}
onNotifySilentUpdateError: {
go.updateState = "updateError"
}
//onNotifySilentUpdateRestartNeeded: {
// go.updateState = "updateRestart"
//}
//
//onNotifySilentUpdateError: {
// go.updateState = "updateError"
//}
onNotifyLogout : {
go.notifyBubble(0, qsTr("Account %1 has been disconnected. Please log in to continue to use the Import-Export app with this account.").arg(accname) )

View File

@ -96,6 +96,8 @@ Item {
onClicked: bugreportWin.show()
}
/*
ButtonIconText {
id: autoUpdates
text: qsTr("Keep the application up to date", "label for toggle that activates and disables the automatic updates")
@ -115,8 +117,6 @@ Item {
}
}
/*
ButtonIconText {
id: cacheClear
text: qsTr("Clear Cache")

View File

@ -107,7 +107,7 @@ Dialog {
text: qsTr("Automatically update in the future", "Checkbox label for using autoupdates later on")
checked: go.isAutoUpdate
onToggled: go.toggleAutoUpdate()
visible: !root.forceUpdate
visible: !root.forceUpdate && (go.isAutoUpdate != undefined)
}
Row {

View File

@ -23,13 +23,13 @@ import QtQuick.Window 2.2
Window {
id : testroot
width : 100
width : 150
height : 600
flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint
visible : true
title : "GUI test Window"
color : "transparent"
x : testgui.winMain.x - 120
x : testgui.winMain.x - 170
y : testgui.winMain.y
property bool newVersion : true
@ -110,8 +110,8 @@ Window {
ListElement { title: "NotifyManualUpdateRestart" }
ListElement { title: "NotifyManualUpdateError" }
ListElement { title: "ForceUpdate" }
ListElement { title: "NotifySilentUpdateRestartNeeded" }
ListElement { title: "NotifySilentUpdateError" }
//ListElement { title: "NotifySilentUpdateRestartNeeded" }
//ListElement { title: "NotifySilentUpdateError" }
ListElement { title : "ImportStructure" }
ListElement { title : "DraftImpFailed" }
ListElement { title : "NoInterImp" }
@ -183,12 +183,12 @@ Window {
case "ForceUpdate" :
go.notifyForceUpdate()
break;
case "NotifySilentUpdateRestartNeeded" :
go.notifySilentUpdateRestartNeeded()
break;
case "NotifySilentUpdateError" :
go.notifySilentUpdateError()
break;
//case "NotifySilentUpdateRestartNeeded" :
//go.notifySilentUpdateRestartNeeded()
//break;
//case "NotifySilentUpdateError" :
//go.notifySilentUpdateError()
//break;
case "ImportStructure" :
testgui.winMain.dialogImport.address = "cuto@pm.com"
testgui.winMain.dialogImport.show()
@ -836,7 +836,7 @@ Window {
id: go
property int isAutoStart : 1
property bool isAutoUpdate : false
//property bool isAutoUpdate : false
property bool isFirstStart : false
property string currentAddress : "none"
//property string goos : "windows"
@ -858,15 +858,15 @@ Window {
property string updateState
property string updateVersion : "q0.1.0"
property bool updateCanInstall: true
property bool updateCanInstall: false
property string updateLandingPage : "https://protonmail.com/import-export/download/"
property string updateReleaseNotesLink : "https://protonmail.com/download/ie/release_notes.html"
signal notifyManualUpdate()
signal notifyManualUpdateRestartNeeded()
signal notifyManualUpdateError()
signal notifyForceUpdate()
signal notifySilentUpdateRestartNeeded()
signal notifySilentUpdateError()
//signal notifySilentUpdateRestartNeeded()
//signal notifySilentUpdateError()
function checkForUpdates() {
console.log("checkForUpdates")
go.notifyVersionIsTheLatest()
@ -1355,10 +1355,10 @@ Window {
return !fname.includes("fail")
}
onToggleAutoUpdate: {
workAndClose()
isAutoUpdate = (isAutoUpdate!=false) ? false : true
console.log (" Test: onToggleAutoUpdate "+isAutoUpdate)
}
//onToggleAutoUpdate: {
// workAndClose()
// isAutoUpdate = (isAutoUpdate!=false) ? false : true
// console.log (" Test: onToggleAutoUpdate "+isAutoUpdate)
//}
}
}

View File

@ -135,11 +135,11 @@ func (f *FrontendQt) SetVersion(version updater.VersionInfo) {
}
func (f *FrontendQt) NotifySilentUpdateInstalled() {
f.Qml.NotifySilentUpdateRestartNeeded()
//f.Qml.NotifySilentUpdateRestartNeeded()
}
func (f *FrontendQt) NotifySilentUpdateError(err error) {
f.Qml.NotifySilentUpdateError()
//f.Qml.NotifySilentUpdateError()
}
func (f *FrontendQt) watchEvents() {
@ -245,11 +245,11 @@ func (f *FrontendQt) QtExecute(Procedure func(*FrontendQt) error) error {
f.Qml.SetCredits(importexport.Credits)
f.Qml.SetFullversion(f.buildVersion)
if f.settings.GetBool(settings.AutoUpdateKey) {
f.Qml.SetIsAutoUpdate(true)
} else {
f.Qml.SetIsAutoUpdate(false)
}
//if f.settings.GetBool(settings.AutoUpdateKey) {
// f.Qml.SetIsAutoUpdate(true)
//} else {
// f.Qml.SetIsAutoUpdate(false)
//}
go func() {
defer f.panicHandler.HandlePanic()
@ -339,17 +339,17 @@ func (f *FrontendQt) sendBug(description, emailClient, address string) bool {
return true
}
func (f *FrontendQt) toggleAutoUpdate() {
defer f.Qml.ProcessFinished()
if f.settings.GetBool(settings.AutoUpdateKey) {
f.settings.SetBool(settings.AutoUpdateKey, false)
f.Qml.SetIsAutoUpdate(false)
} else {
f.settings.SetBool(settings.AutoUpdateKey, true)
f.Qml.SetIsAutoUpdate(true)
}
}
//func (f *FrontendQt) toggleAutoUpdate() {
// defer f.Qml.ProcessFinished()
//
// if f.settings.GetBool(settings.AutoUpdateKey) {
// f.settings.SetBool(settings.AutoUpdateKey, false)
// f.Qml.SetIsAutoUpdate(false)
// } else {
// f.settings.SetBool(settings.AutoUpdateKey, true)
// f.Qml.SetIsAutoUpdate(true)
// }
//}
// checkInternet is almost idetical to bridge
func (f *FrontendQt) checkInternet() {

View File

@ -33,7 +33,7 @@ type GoQMLInterface struct {
_ func() `constructor:"init"`
_ bool `property:"isAutoUpdate"`
//_ bool `property:"isAutoUpdate"`
_ string `property:"currentAddress"`
_ string `property:"goos"`
_ string `property:"credits"`
@ -62,8 +62,8 @@ type GoQMLInterface struct {
_ func() `signal:"notifyManualUpdateRestartNeeded"`
_ func() `signal:"notifyManualUpdateError"`
_ func() `signal:"notifyForceUpdate"`
_ func() `signal:"notifySilentUpdateRestartNeeded"`
_ func() `signal:"notifySilentUpdateError"`
//_ func() `signal:"notifySilentUpdateRestartNeeded"`
//_ func() `signal:"notifySilentUpdateError"`
_ func() `slot:"checkForUpdates"`
_ func() `slot:"checkAndOpenReleaseNotes"`
_ func() `signal:"openReleaseNotesExternally"`
@ -93,7 +93,7 @@ type GoQMLInterface struct {
_ func() `signal:"showWindow"`
_ func() `slot:"toggleAutoUpdate"`
//_ func() `slot:"toggleAutoUpdate"`
_ func() `slot:"quit"`
_ func() `slot:"loadAccounts"`
_ func() `slot:"openLogs"`
@ -162,7 +162,7 @@ func (s *GoQMLInterface) init() {}
func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
s.ConnectQuit(f.App.Quit)
s.ConnectToggleAutoUpdate(f.toggleAutoUpdate)
//s.ConnectToggleAutoUpdate(f.toggleAutoUpdate)
s.ConnectLoadAccounts(f.Accounts.LoadAccounts)
s.ConnectOpenLogs(f.openLogs)
s.ConnectOpenDownloadLink(f.openDownloadLink)
@ -207,4 +207,6 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
s.ConnectCheckPathStatus(CheckPathStatus)
s.ConnectEmitEvent(f.emitEvent)
s.ConnectStartManualUpdate(f.startManualUpdate)
}