fix(GODT-2272): use shorter filename for gRPC file socket.
This commit is contained in:
parent
e382687168
commit
342a2a5568
|
@ -89,6 +89,6 @@ There are now three types of system folders which Bridge recognises:
|
|||
| gluon messages | sata | gluon/backend/store |
|
||||
| Update files | data | updates |
|
||||
| sentry cache | data | sentry_cache |
|
||||
| Mac/Linux File Socket | temp | bridge_{RANDOM_UUID}.sock |
|
||||
| Mac/Linux File Socket | temp | bridge{4_DIGITS} |
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -580,10 +581,17 @@ func (s *Service) monitorParentPID() {
|
|||
func computeFileSocketPath() (string, error) {
|
||||
tempPath := os.TempDir()
|
||||
for i := 0; i < 1000; i++ {
|
||||
path := filepath.Join(tempPath, fmt.Sprintf("bridge_%v.sock", uuid.NewString()))
|
||||
path := filepath.Join(tempPath, fmt.Sprintf("bridge%04d", rand.Intn(10000))) // nolint:gosec
|
||||
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
|
||||
return path, nil
|
||||
}
|
||||
|
||||
if err := os.Remove(path); err != nil {
|
||||
logrus.WithField("path", path).WithError(err).Warning("Could not remove existing socket file")
|
||||
continue
|
||||
}
|
||||
|
||||
return path, nil
|
||||
}
|
||||
|
||||
return "", errors.New("unable to find a suitable file socket in user config folder")
|
||||
|
|
Loading…
Reference in New Issue