forked from Silverfish/proton-bridge
GODT-1047 No silent updates for Import-Export app
This commit is contained in:
committed by
Alexander Bilyak
parent
27541784aa
commit
a0132e8440
@ -28,8 +28,6 @@ import (
|
|||||||
"github.com/ProtonMail/proton-bridge/internal/frontend"
|
"github.com/ProtonMail/proton-bridge/internal/frontend"
|
||||||
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
|
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
|
||||||
"github.com/ProtonMail/proton-bridge/internal/importexport"
|
"github.com/ProtonMail/proton-bridge/internal/importexport"
|
||||||
"github.com/ProtonMail/proton-bridge/internal/updater"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@ -88,7 +86,7 @@ func run(b *base.Base, c *cli.Context) error {
|
|||||||
return f.Loop()
|
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()
|
version, err := u.Check()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("An error occurred while checking for updates")
|
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")
|
logrus.WithField("version", version.Version).Info("An update is available")
|
||||||
|
|
||||||
if !autoUpdate {
|
|
||||||
f.NotifyManualUpdate(version, u.CanInstall(version))
|
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()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -236,13 +236,13 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNotifySilentUpdateRestartNeeded: {
|
//onNotifySilentUpdateRestartNeeded: {
|
||||||
go.updateState = "updateRestart"
|
// go.updateState = "updateRestart"
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
onNotifySilentUpdateError: {
|
//onNotifySilentUpdateError: {
|
||||||
go.updateState = "updateError"
|
// go.updateState = "updateError"
|
||||||
}
|
//}
|
||||||
|
|
||||||
onNotifyLogout : {
|
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) )
|
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) )
|
||||||
|
|||||||
@ -96,6 +96,8 @@ Item {
|
|||||||
onClicked: bugreportWin.show()
|
onClicked: bugreportWin.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
ButtonIconText {
|
ButtonIconText {
|
||||||
id: autoUpdates
|
id: autoUpdates
|
||||||
text: qsTr("Keep the application up to date", "label for toggle that activates and disables the automatic updates")
|
text: qsTr("Keep the application up to date", "label for toggle that activates and disables the automatic updates")
|
||||||
@ -115,8 +117,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
ButtonIconText {
|
ButtonIconText {
|
||||||
id: cacheClear
|
id: cacheClear
|
||||||
text: qsTr("Clear Cache")
|
text: qsTr("Clear Cache")
|
||||||
|
|||||||
@ -107,7 +107,7 @@ Dialog {
|
|||||||
text: qsTr("Automatically update in the future", "Checkbox label for using autoupdates later on")
|
text: qsTr("Automatically update in the future", "Checkbox label for using autoupdates later on")
|
||||||
checked: go.isAutoUpdate
|
checked: go.isAutoUpdate
|
||||||
onToggled: go.toggleAutoUpdate()
|
onToggled: go.toggleAutoUpdate()
|
||||||
visible: !root.forceUpdate
|
visible: !root.forceUpdate && (go.isAutoUpdate != undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|||||||
@ -23,13 +23,13 @@ import QtQuick.Window 2.2
|
|||||||
|
|
||||||
Window {
|
Window {
|
||||||
id : testroot
|
id : testroot
|
||||||
width : 100
|
width : 150
|
||||||
height : 600
|
height : 600
|
||||||
flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint
|
flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint
|
||||||
visible : true
|
visible : true
|
||||||
title : "GUI test Window"
|
title : "GUI test Window"
|
||||||
color : "transparent"
|
color : "transparent"
|
||||||
x : testgui.winMain.x - 120
|
x : testgui.winMain.x - 170
|
||||||
y : testgui.winMain.y
|
y : testgui.winMain.y
|
||||||
|
|
||||||
property bool newVersion : true
|
property bool newVersion : true
|
||||||
@ -110,8 +110,8 @@ Window {
|
|||||||
ListElement { title: "NotifyManualUpdateRestart" }
|
ListElement { title: "NotifyManualUpdateRestart" }
|
||||||
ListElement { title: "NotifyManualUpdateError" }
|
ListElement { title: "NotifyManualUpdateError" }
|
||||||
ListElement { title: "ForceUpdate" }
|
ListElement { title: "ForceUpdate" }
|
||||||
ListElement { title: "NotifySilentUpdateRestartNeeded" }
|
//ListElement { title: "NotifySilentUpdateRestartNeeded" }
|
||||||
ListElement { title: "NotifySilentUpdateError" }
|
//ListElement { title: "NotifySilentUpdateError" }
|
||||||
ListElement { title : "ImportStructure" }
|
ListElement { title : "ImportStructure" }
|
||||||
ListElement { title : "DraftImpFailed" }
|
ListElement { title : "DraftImpFailed" }
|
||||||
ListElement { title : "NoInterImp" }
|
ListElement { title : "NoInterImp" }
|
||||||
@ -183,12 +183,12 @@ Window {
|
|||||||
case "ForceUpdate" :
|
case "ForceUpdate" :
|
||||||
go.notifyForceUpdate()
|
go.notifyForceUpdate()
|
||||||
break;
|
break;
|
||||||
case "NotifySilentUpdateRestartNeeded" :
|
//case "NotifySilentUpdateRestartNeeded" :
|
||||||
go.notifySilentUpdateRestartNeeded()
|
//go.notifySilentUpdateRestartNeeded()
|
||||||
break;
|
//break;
|
||||||
case "NotifySilentUpdateError" :
|
//case "NotifySilentUpdateError" :
|
||||||
go.notifySilentUpdateError()
|
//go.notifySilentUpdateError()
|
||||||
break;
|
//break;
|
||||||
case "ImportStructure" :
|
case "ImportStructure" :
|
||||||
testgui.winMain.dialogImport.address = "cuto@pm.com"
|
testgui.winMain.dialogImport.address = "cuto@pm.com"
|
||||||
testgui.winMain.dialogImport.show()
|
testgui.winMain.dialogImport.show()
|
||||||
@ -836,7 +836,7 @@ Window {
|
|||||||
id: go
|
id: go
|
||||||
|
|
||||||
property int isAutoStart : 1
|
property int isAutoStart : 1
|
||||||
property bool isAutoUpdate : false
|
//property bool isAutoUpdate : false
|
||||||
property bool isFirstStart : false
|
property bool isFirstStart : false
|
||||||
property string currentAddress : "none"
|
property string currentAddress : "none"
|
||||||
//property string goos : "windows"
|
//property string goos : "windows"
|
||||||
@ -858,15 +858,15 @@ Window {
|
|||||||
|
|
||||||
property string updateState
|
property string updateState
|
||||||
property string updateVersion : "q0.1.0"
|
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 updateLandingPage : "https://protonmail.com/import-export/download/"
|
||||||
property string updateReleaseNotesLink : "https://protonmail.com/download/ie/release_notes.html"
|
property string updateReleaseNotesLink : "https://protonmail.com/download/ie/release_notes.html"
|
||||||
signal notifyManualUpdate()
|
signal notifyManualUpdate()
|
||||||
signal notifyManualUpdateRestartNeeded()
|
signal notifyManualUpdateRestartNeeded()
|
||||||
signal notifyManualUpdateError()
|
signal notifyManualUpdateError()
|
||||||
signal notifyForceUpdate()
|
signal notifyForceUpdate()
|
||||||
signal notifySilentUpdateRestartNeeded()
|
//signal notifySilentUpdateRestartNeeded()
|
||||||
signal notifySilentUpdateError()
|
//signal notifySilentUpdateError()
|
||||||
function checkForUpdates() {
|
function checkForUpdates() {
|
||||||
console.log("checkForUpdates")
|
console.log("checkForUpdates")
|
||||||
go.notifyVersionIsTheLatest()
|
go.notifyVersionIsTheLatest()
|
||||||
@ -1355,10 +1355,10 @@ Window {
|
|||||||
return !fname.includes("fail")
|
return !fname.includes("fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggleAutoUpdate: {
|
//onToggleAutoUpdate: {
|
||||||
workAndClose()
|
// workAndClose()
|
||||||
isAutoUpdate = (isAutoUpdate!=false) ? false : true
|
// isAutoUpdate = (isAutoUpdate!=false) ? false : true
|
||||||
console.log (" Test: onToggleAutoUpdate "+isAutoUpdate)
|
// console.log (" Test: onToggleAutoUpdate "+isAutoUpdate)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,11 +135,11 @@ func (f *FrontendQt) SetVersion(version updater.VersionInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) NotifySilentUpdateInstalled() {
|
func (f *FrontendQt) NotifySilentUpdateInstalled() {
|
||||||
f.Qml.NotifySilentUpdateRestartNeeded()
|
//f.Qml.NotifySilentUpdateRestartNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) NotifySilentUpdateError(err error) {
|
func (f *FrontendQt) NotifySilentUpdateError(err error) {
|
||||||
f.Qml.NotifySilentUpdateError()
|
//f.Qml.NotifySilentUpdateError()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) watchEvents() {
|
func (f *FrontendQt) watchEvents() {
|
||||||
@ -245,11 +245,11 @@ func (f *FrontendQt) QtExecute(Procedure func(*FrontendQt) error) error {
|
|||||||
f.Qml.SetCredits(importexport.Credits)
|
f.Qml.SetCredits(importexport.Credits)
|
||||||
f.Qml.SetFullversion(f.buildVersion)
|
f.Qml.SetFullversion(f.buildVersion)
|
||||||
|
|
||||||
if f.settings.GetBool(settings.AutoUpdateKey) {
|
//if f.settings.GetBool(settings.AutoUpdateKey) {
|
||||||
f.Qml.SetIsAutoUpdate(true)
|
// f.Qml.SetIsAutoUpdate(true)
|
||||||
} else {
|
//} else {
|
||||||
f.Qml.SetIsAutoUpdate(false)
|
// f.Qml.SetIsAutoUpdate(false)
|
||||||
}
|
//}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer f.panicHandler.HandlePanic()
|
defer f.panicHandler.HandlePanic()
|
||||||
@ -339,17 +339,17 @@ func (f *FrontendQt) sendBug(description, emailClient, address string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FrontendQt) toggleAutoUpdate() {
|
//func (f *FrontendQt) toggleAutoUpdate() {
|
||||||
defer f.Qml.ProcessFinished()
|
// defer f.Qml.ProcessFinished()
|
||||||
|
//
|
||||||
if f.settings.GetBool(settings.AutoUpdateKey) {
|
// if f.settings.GetBool(settings.AutoUpdateKey) {
|
||||||
f.settings.SetBool(settings.AutoUpdateKey, false)
|
// f.settings.SetBool(settings.AutoUpdateKey, false)
|
||||||
f.Qml.SetIsAutoUpdate(false)
|
// f.Qml.SetIsAutoUpdate(false)
|
||||||
} else {
|
// } else {
|
||||||
f.settings.SetBool(settings.AutoUpdateKey, true)
|
// f.settings.SetBool(settings.AutoUpdateKey, true)
|
||||||
f.Qml.SetIsAutoUpdate(true)
|
// f.Qml.SetIsAutoUpdate(true)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
// checkInternet is almost idetical to bridge
|
// checkInternet is almost idetical to bridge
|
||||||
func (f *FrontendQt) checkInternet() {
|
func (f *FrontendQt) checkInternet() {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ type GoQMLInterface struct {
|
|||||||
|
|
||||||
_ func() `constructor:"init"`
|
_ func() `constructor:"init"`
|
||||||
|
|
||||||
_ bool `property:"isAutoUpdate"`
|
//_ bool `property:"isAutoUpdate"`
|
||||||
_ string `property:"currentAddress"`
|
_ string `property:"currentAddress"`
|
||||||
_ string `property:"goos"`
|
_ string `property:"goos"`
|
||||||
_ string `property:"credits"`
|
_ string `property:"credits"`
|
||||||
@ -62,8 +62,8 @@ type GoQMLInterface struct {
|
|||||||
_ func() `signal:"notifyManualUpdateRestartNeeded"`
|
_ func() `signal:"notifyManualUpdateRestartNeeded"`
|
||||||
_ func() `signal:"notifyManualUpdateError"`
|
_ func() `signal:"notifyManualUpdateError"`
|
||||||
_ func() `signal:"notifyForceUpdate"`
|
_ func() `signal:"notifyForceUpdate"`
|
||||||
_ func() `signal:"notifySilentUpdateRestartNeeded"`
|
//_ func() `signal:"notifySilentUpdateRestartNeeded"`
|
||||||
_ func() `signal:"notifySilentUpdateError"`
|
//_ func() `signal:"notifySilentUpdateError"`
|
||||||
_ func() `slot:"checkForUpdates"`
|
_ func() `slot:"checkForUpdates"`
|
||||||
_ func() `slot:"checkAndOpenReleaseNotes"`
|
_ func() `slot:"checkAndOpenReleaseNotes"`
|
||||||
_ func() `signal:"openReleaseNotesExternally"`
|
_ func() `signal:"openReleaseNotesExternally"`
|
||||||
@ -93,7 +93,7 @@ type GoQMLInterface struct {
|
|||||||
|
|
||||||
_ func() `signal:"showWindow"`
|
_ func() `signal:"showWindow"`
|
||||||
|
|
||||||
_ func() `slot:"toggleAutoUpdate"`
|
//_ func() `slot:"toggleAutoUpdate"`
|
||||||
_ func() `slot:"quit"`
|
_ func() `slot:"quit"`
|
||||||
_ func() `slot:"loadAccounts"`
|
_ func() `slot:"loadAccounts"`
|
||||||
_ func() `slot:"openLogs"`
|
_ func() `slot:"openLogs"`
|
||||||
@ -162,7 +162,7 @@ func (s *GoQMLInterface) init() {}
|
|||||||
func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||||
s.ConnectQuit(f.App.Quit)
|
s.ConnectQuit(f.App.Quit)
|
||||||
|
|
||||||
s.ConnectToggleAutoUpdate(f.toggleAutoUpdate)
|
//s.ConnectToggleAutoUpdate(f.toggleAutoUpdate)
|
||||||
s.ConnectLoadAccounts(f.Accounts.LoadAccounts)
|
s.ConnectLoadAccounts(f.Accounts.LoadAccounts)
|
||||||
s.ConnectOpenLogs(f.openLogs)
|
s.ConnectOpenLogs(f.openLogs)
|
||||||
s.ConnectOpenDownloadLink(f.openDownloadLink)
|
s.ConnectOpenDownloadLink(f.openDownloadLink)
|
||||||
@ -207,4 +207,6 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
|||||||
s.ConnectCheckPathStatus(CheckPathStatus)
|
s.ConnectCheckPathStatus(CheckPathStatus)
|
||||||
|
|
||||||
s.ConnectEmitEvent(f.emitEvent)
|
s.ConnectEmitEvent(f.emitEvent)
|
||||||
|
|
||||||
|
s.ConnectStartManualUpdate(f.startManualUpdate)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user