mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
Revert "GODT-2039: bridge monitors bridge-gui via its PID."
This reverts commit 3b9a3aaad2.
This commit is contained in:
@ -76,7 +76,6 @@ const (
|
||||
flagRestart = "restart"
|
||||
FlagLauncher = "launcher"
|
||||
FlagNoWindow = "no-window"
|
||||
FlagParentPID = "parent-pid"
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
@ -325,12 +324,6 @@ func (b *Base) NewApp(mainLoop func(*Base, *cli.Context) error) *cli.App {
|
||||
Usage: "The launcher to use to restart the application",
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: FlagParentPID,
|
||||
Usage: "The PID of the process that started the application. Ignored if frontend is not gRPC",
|
||||
Hidden: true,
|
||||
Value: -1,
|
||||
},
|
||||
}
|
||||
|
||||
return app
|
||||
|
||||
@ -20,7 +20,6 @@ package base
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/execabs"
|
||||
@ -39,8 +38,6 @@ func (b *Base) restartApp(crash bool) error {
|
||||
args = os.Args[1:]
|
||||
}
|
||||
|
||||
args = removeFlagWithValue(args, FlagParentPID)
|
||||
|
||||
if b.launcher != "" {
|
||||
args = forceLauncherFlag(args, b.launcher)
|
||||
}
|
||||
@ -88,30 +85,6 @@ func incrementRestartFlag(args []string) []string {
|
||||
return res
|
||||
}
|
||||
|
||||
// removeFlagWithValue removes a flag that requires a value from a list of command line parameters.
|
||||
// The flag can be of the following form `-flag value`, `--flag value`, `-flag=value` or `--flags=value`.
|
||||
func removeFlagWithValue(argList []string, flag string) []string {
|
||||
var result []string
|
||||
|
||||
for i := 0; i < len(argList); i++ {
|
||||
arg := argList[i]
|
||||
// "detect the parameter form "-flag value" or "--paramName value"
|
||||
if (arg == "-"+flag) || (arg == "--"+flag) {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
// "detect the form "--flag=value" or "--flag=value"
|
||||
if strings.HasPrefix(arg, "-"+flag+"=") || (strings.HasPrefix(arg, "--"+flag+"=")) {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, arg)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// forceLauncherFlag replace or add the launcher args with the one set in the app.
|
||||
func forceLauncherFlag(args []string, launcher string) []string {
|
||||
res := append([]string{}, args...)
|
||||
|
||||
@ -61,22 +61,3 @@ func TestVersionLessThan(t *testing.T) {
|
||||
r.False(current.LessThan(current))
|
||||
r.False(newer.LessThan(current))
|
||||
}
|
||||
|
||||
func TestRemoveFlagWithValue(t *testing.T) {
|
||||
tests := []struct {
|
||||
argList []string
|
||||
flag string
|
||||
expected []string
|
||||
}{
|
||||
{[]string{}, "b", nil},
|
||||
{[]string{"-a", "-b=value", "-c"}, "b", []string{"-a", "-c"}},
|
||||
{[]string{"-a", "--b=value", "-c"}, "b", []string{"-a", "-c"}},
|
||||
{[]string{"-a", "-b", "value", "-c"}, "b", []string{"-a", "-c"}},
|
||||
{[]string{"-a", "--b", "value", "-c"}, "b", []string{"-a", "-c"}},
|
||||
{[]string{"-a", "-B=value", "-c"}, "b", []string{"-a", "-B=value", "-c"}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
require.Equal(t, removeFlagWithValue(tt.argList, tt.flag), tt.expected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,6 @@ func main(b *base.Base, c *cli.Context) error { //nolint:funlen
|
||||
b.Updater,
|
||||
b,
|
||||
b.Locations,
|
||||
c.Int(base.FlagParentPID),
|
||||
)
|
||||
|
||||
cache, cacheErr := loadMessageCache(b)
|
||||
|
||||
Reference in New Issue
Block a user