GODT-2010: Add better logging for app focus feature

This commit is contained in:
James Houlahan
2022-11-01 13:16:32 +01:00
parent 99745ac067
commit 1dbc9a1366
2 changed files with 49 additions and 45 deletions

View File

@ -31,6 +31,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/ProtonMail/proton-bridge/v2/internal/focus"
"github.com/allan-simon/go-singleinstance"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
@ -42,9 +43,12 @@ import (
// it will kill old and continue with this new bridge (i.e. no error returned).
func checkSingleInstance(lockFilePath string, curVersion *semver.Version) (*os.File, error) {
if lock, err := singleinstance.CreateLockFile(lockFilePath); err == nil {
logrus.WithField("path", lockFilePath).Debug("Created lock file; no other instance is running")
return lock, nil
}
logrus.Debug("Failed to create lock file; another instance is running")
// We couldn't create the lock file, so another instance is probably running.
// Check if it's an older version of the app.
lastVersion, ok := focus.TryVersion()