forked from Silverfish/proton-bridge
Other: require go 1.18 and update to golangci-lint to latest revision + fixes.
This commit is contained in:
@ -40,7 +40,7 @@ const (
|
||||
venturaPreferencesPane = "x-apple.systempreferences:com.apple.preferences.configurationprofiles"
|
||||
)
|
||||
|
||||
func init() { //nolint:gochecknoinit
|
||||
func init() { //nolint:gochecknoinits
|
||||
available[AppleMailClient] = &appleMail{}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ func (c *appleMail) Configure(imapPort, smtpPort int, imapSSL, smtpSSL bool, use
|
||||
return execabs.Command("open", prefPane, confPath).Run() //nolint:gosec // G204 open command is safe, mobileconfig is generated by us
|
||||
}
|
||||
|
||||
return execabs.Command("open", confPath).Run() //nolint:gosec G204: open command is safe, mobileconfig is generated by us
|
||||
return execabs.Command("open", confPath).Run() //nolint:gosec // G204 open command is safe, mobileconfig is generated by us
|
||||
}
|
||||
|
||||
func prepareMobileConfig(imapPort, smtpPort int, imapSSL, smtpSSL bool, user types.User, address string) *mobileconfig.Config {
|
||||
@ -114,7 +114,7 @@ func saveConfigTemporarily(mc *mobileconfig.Config) (fname string, err error) {
|
||||
|
||||
// Make sure the file is only readable for the current user.
|
||||
fname = filepath.Clean(filepath.Join(dir, "protonmail.mobileconfig"))
|
||||
f, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE, 0o600)
|
||||
f, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE, 0o600) //nolint:gosec
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ type Service struct { // nolint:structcheck
|
||||
settings *settings.Settings
|
||||
eventListener listener.Listener
|
||||
updater types.Updater
|
||||
updateCheckMutex sync.Mutex
|
||||
userAgent *useragent.UserAgent
|
||||
bridge types.Bridger
|
||||
restarter types.Restarter
|
||||
@ -331,10 +332,7 @@ func (s *Service) restart() {
|
||||
s.log.Error("Restart is not implemented") // TO-DO GODT-1671 implement restart.
|
||||
}
|
||||
|
||||
var checkingUpdates = sync.Mutex{}
|
||||
|
||||
func (s *Service) checkUpdate() {
|
||||
|
||||
version, err := s.updater.Check()
|
||||
if err != nil {
|
||||
s.log.WithError(err).Error("An error occurred while checking for updates")
|
||||
@ -345,22 +343,22 @@ func (s *Service) checkUpdate() {
|
||||
}
|
||||
|
||||
func (s *Service) updateForce() {
|
||||
checkingUpdates.Lock()
|
||||
defer checkingUpdates.Unlock()
|
||||
s.updateCheckMutex.Lock()
|
||||
defer s.updateCheckMutex.Unlock()
|
||||
s.checkUpdate()
|
||||
_ = s.SendEvent(NewUpdateForceEvent(s.newVersionInfo.Version.String()))
|
||||
}
|
||||
|
||||
func (s *Service) checkUpdateAndNotify(isReqFromUser bool) {
|
||||
checkingUpdates.Lock()
|
||||
s.updateCheckMutex.Lock()
|
||||
defer func() {
|
||||
checkingUpdates.Unlock()
|
||||
s.updateCheckMutex.Unlock()
|
||||
_ = s.SendEvent(NewUpdateCheckFinishedEvent())
|
||||
}()
|
||||
|
||||
s.checkUpdate()
|
||||
version := s.newVersionInfo
|
||||
if "" == version.Version.String() {
|
||||
if version.Version.String() == "" {
|
||||
if isReqFromUser {
|
||||
_ = s.SendEvent(NewUpdateErrorEvent(UpdateErrorType_UPDATE_MANUAL_ERROR))
|
||||
}
|
||||
@ -377,8 +375,8 @@ func (s *Service) checkUpdateAndNotify(isReqFromUser bool) {
|
||||
}
|
||||
|
||||
func (s *Service) installUpdate() {
|
||||
checkingUpdates.Lock()
|
||||
defer checkingUpdates.Unlock()
|
||||
s.updateCheckMutex.Lock()
|
||||
defer s.updateCheckMutex.Unlock()
|
||||
|
||||
if !s.updater.CanInstall(s.newVersionInfo) {
|
||||
s.log.Warning("Skipping update installation, current version too old")
|
||||
|
||||
@ -34,14 +34,14 @@ func detectSystemTheme() Theme {
|
||||
}
|
||||
|
||||
path := filepath.Join(home, "/Library/Preferences/.GlobalPreferences.plist")
|
||||
prefFile, err := os.Open(path)
|
||||
prefFile, err := os.Open(path) //nolint:gosec // file is safe
|
||||
if err != nil {
|
||||
return Light
|
||||
}
|
||||
defer prefFile.Close()
|
||||
defer func() { _ = prefFile.Close() }()
|
||||
|
||||
var data struct {
|
||||
AppleInterfaceStyle string `plist:AppleInterfaceStyle`
|
||||
AppleInterfaceStyle string `plist:"AppleInterfaceStyle"`
|
||||
}
|
||||
|
||||
dec := plist.NewDecoder(prefFile)
|
||||
|
||||
@ -34,7 +34,7 @@ func (v *Versioner) RemoveOtherVersions(versionToKeep *semver.Version) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveOtherVersions removes current app version unless it is base installed version.
|
||||
// RemoveCurrentVersion removes current app version unless it is base installed version.
|
||||
func (v *Versioner) RemoveCurrentVersion() error {
|
||||
// darwin does not use the versioner; removal is a noop.
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user