🎨 Data sync connectivity check supports redirection Fix https://github.com/siyuan-note/siyuan/issues/8264

This commit is contained in:
Liang Ding 2023-05-16 09:09:31 +08:00
parent d24f5ae3cf
commit 516276db49
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 14 additions and 2 deletions

View file

@ -139,7 +139,7 @@ func BootSyncData() {
if !isProviderOnline(false) {
BootSyncSucc = 1
util.PushErrMsg(Conf.Language(28), 7000)
util.PushErrMsg(Conf.Language(76), 7000)
return
}

View file

@ -57,7 +57,19 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
}
for i := 0; i < 3; i++ {
_, err := c.R().Get(checkURL)
resp, err := c.R().Get(checkURL)
if resp.GetHeader("Location") != "" {
return true
}
switch err.(type) {
case *url.Error:
if err.(*url.Error).URL != checkURL {
// DNS 重定向
return true
}
}
ret = nil == err
if ret {
break