fix(notice): disable notice when we're not connected

resolves #5325
This commit is contained in:
Jan De Dobbeleer 2024-07-22 11:36:45 +02:00 committed by Jan De Dobbeleer
parent 7ab48aff70
commit cd9c7f58d8
2 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,14 @@
package http
import (
"net"
"time"
)
// if we can connect to google within 200ms, we are connected
// otherwise, let's consider being offline
func IsConnected() bool {
timeout := 200 * time.Millisecond
_, err := net.DialTimeout("tcp", "google.com:80", timeout)
return err == nil
}

View file

@ -7,6 +7,7 @@ import (
"github.com/jandedobbeleer/oh-my-posh/src/build"
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
"github.com/jandedobbeleer/oh-my-posh/src/runtime/http"
)
type release struct {
@ -67,6 +68,10 @@ func Notice(env runtime.Environment, force bool) (string, bool) {
return "", false
}
if !http.IsConnected() {
return "", false
}
// never validate when we install using the Windows Store
if env.Getenv("POSH_INSTALLER") == "ws" {
return "", false