🎨 Improve WebDAV/S3 data sync request timeout settings https://github.com/siyuan-note/siyuan/issues/12734
This commit is contained in:
parent
61e07a1ed1
commit
e334478214
3 changed files with 9 additions and 6 deletions
|
@ -484,7 +484,7 @@ func isOutdatedTemplate(template *Template, bazaarTemplates []*Template) bool {
|
|||
|
||||
func isBazzarOnline() (ret bool) {
|
||||
// Improve marketplace loading when offline https://github.com/siyuan-note/siyuan/issues/12050
|
||||
ret = util.IsOnline(util.BazaarOSSServer, true)
|
||||
ret = util.IsOnline(util.BazaarOSSServer, true, 3000)
|
||||
if !ret {
|
||||
util.PushErrMsg(util.Langs[util.Lang][24], 5000)
|
||||
}
|
||||
|
|
|
@ -648,20 +648,23 @@ func planSyncAfter(d time.Duration) {
|
|||
func isProviderOnline(byHand bool) (ret bool) {
|
||||
checkURL := util.GetCloudSyncServer()
|
||||
skipTlsVerify := false
|
||||
timeout := 3000
|
||||
switch Conf.Sync.Provider {
|
||||
case conf.ProviderSiYuan:
|
||||
case conf.ProviderS3:
|
||||
checkURL = Conf.Sync.S3.Endpoint
|
||||
skipTlsVerify = Conf.Sync.S3.SkipTlsVerify
|
||||
timeout = Conf.Sync.S3.Timeout * 1000
|
||||
case conf.ProviderWebDAV:
|
||||
checkURL = Conf.Sync.WebDAV.Endpoint
|
||||
skipTlsVerify = Conf.Sync.WebDAV.SkipTlsVerify
|
||||
timeout = Conf.Sync.WebDAV.Timeout * 1000
|
||||
default:
|
||||
logging.LogWarnf("unknown provider: %d", Conf.Sync.Provider)
|
||||
return false
|
||||
}
|
||||
|
||||
if ret = util.IsOnline(checkURL, skipTlsVerify); !ret {
|
||||
if ret = util.IsOnline(checkURL, skipTlsVerify, timeout); !ret {
|
||||
if 1 > autoSyncErrCount || byHand {
|
||||
util.PushErrMsg(Conf.Language(76)+" (Provider: "+conf.ProviderToStr(Conf.Sync.Provider)+")", 5000)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue