🎨 Improve WebDAV/S3 data sync request timeout settings https://github.com/siyuan-note/siyuan/issues/12734

This commit is contained in:
Daniel 2024-10-08 17:06:13 +08:00
parent 61e07a1ed1
commit e334478214
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 9 additions and 6 deletions

View file

@ -72,7 +72,7 @@ func IsLocalOrigin(origin string) bool {
return false
}
func IsOnline(checkURL string, skipTlsVerify bool) bool {
func IsOnline(checkURL string, skipTlsVerify bool, timeout int) bool {
_, err := url.Parse(checkURL)
if err != nil {
logging.LogWarnf("invalid check URL [%s]", checkURL)
@ -83,7 +83,7 @@ func IsOnline(checkURL string, skipTlsVerify bool) bool {
return false
}
if isOnline(checkURL, skipTlsVerify) {
if isOnline(checkURL, skipTlsVerify, timeout) {
return true
}
@ -104,8 +104,8 @@ func IsPortOpen(port string) bool {
return false
}
func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
c := req.C().SetTimeout(3 * time.Second)
func isOnline(checkURL string, skipTlsVerify bool, timeout int) (ret bool) {
c := req.C().SetTimeout(time.Duration(timeout) * time.Millisecond)
if skipTlsVerify {
c.EnableInsecureSkipVerify()
}