GODT-976 Exclude updates from clearing cache and clear cache, including updates, while switching early access off

This commit is contained in:
Michal Horejsek
2021-01-27 09:16:04 +01:00
parent c6107dbd4b
commit 7468ed7dc0
18 changed files with 241 additions and 13 deletions

View File

@ -26,6 +26,7 @@ import (
"github.com/ProtonMail/proton-bridge/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/events"
"github.com/ProtonMail/proton-bridge/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/keychain"
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi"
)
@ -80,6 +81,15 @@ func (s *FrontendQt) loadAccounts() {
func (s *FrontendQt) clearCache() {
defer s.Qml.ProcessFinished()
channel := s.bridge.GetUpdateChannel()
if channel == updater.EarlyChannel {
if err := s.bridge.SetUpdateChannel(updater.StableChannel); err != nil {
s.Qml.NotifyManualUpdateError()
return
}
}
if err := s.bridge.ClearData(); err != nil {
log.Error("While clearing cache: ", err)
}

View File

@ -578,13 +578,21 @@ func (s *FrontendQt) toggleAutoUpdate() {
func (s *FrontendQt) toggleEarlyAccess() {
defer s.Qml.ProcessFinished()
if updater.UpdateChannel(s.settings.Get(settings.UpdateChannelKey)) == updater.EarlyChannel {
s.settings.Set(settings.UpdateChannelKey, string(updater.StableChannel))
s.Qml.SetIsEarlyAccess(false)
channel := s.bridge.GetUpdateChannel()
if channel == updater.EarlyChannel {
channel = updater.StableChannel
} else {
s.settings.Set(settings.UpdateChannelKey, string(updater.EarlyChannel))
s.Qml.SetIsEarlyAccess(true)
channel = updater.EarlyChannel
}
err := s.bridge.SetUpdateChannel(channel)
s.Qml.SetIsEarlyAccess(channel == updater.EarlyChannel)
if err != nil {
s.Qml.NotifyManualUpdateError()
return
}
s.restarter.SetToRestart()
s.App.Quit()
}
func (s *FrontendQt) toggleAllowProxy() {