mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🐛 集市包下载进度没有展现 https://github.com/siyuan-note/siyuan/issues/6862
This commit is contained in:
parent
f0972a046e
commit
4cea235f9f
1 changed files with 11 additions and 12 deletions
|
@ -305,22 +305,21 @@ func downloadPackage(repoURLHash string, pushProgress bool, systemID string) (da
|
||||||
repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/")
|
repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/")
|
||||||
u := util.BazaarOSSServer + "/package/" + repoURLHash
|
u := util.BazaarOSSServer + "/package/" + repoURLHash
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
resp, err := httpclient.NewBrowserRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
resp, err := req.C().
|
||||||
|
SetUserAgent(util.UserAgent).
|
||||||
|
SetTimeout(30 * time.Second).
|
||||||
|
DisableInsecureSkipVerify().
|
||||||
|
R().SetRetryCount(1).
|
||||||
|
SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
||||||
if pushProgress {
|
if pushProgress {
|
||||||
util.PushDownloadProgress(pushID, float32(info.DownloadedSize)/float32(info.Response.ContentLength))
|
progress := float32(info.DownloadedSize) / float32(info.Response.ContentLength)
|
||||||
|
logging.LogDebugf("downloading bazaar package [%d]", progress)
|
||||||
|
util.PushDownloadProgress(pushID, progress)
|
||||||
}
|
}
|
||||||
}).Get(u)
|
}).Get(u)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
u = util.BazaarOSSServer + "/package/" + repoURLHash
|
logging.LogErrorf("get bazaar package [%s] failed: %s", u, err)
|
||||||
resp, err = httpclient.NewBrowserRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
|
return nil, errors.New("get bazaar package failed")
|
||||||
if pushProgress {
|
|
||||||
util.PushDownloadProgress(pushID, float32(info.DownloadedSize)/float32(info.Response.ContentLength))
|
|
||||||
}
|
|
||||||
}).Get(u)
|
|
||||||
if nil != err {
|
|
||||||
logging.LogErrorf("get bazaar package [%s] failed: %s", u, err)
|
|
||||||
return nil, errors.New("get bazaar package failed")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if 200 != resp.StatusCode {
|
if 200 != resp.StatusCode {
|
||||||
logging.LogErrorf("get bazaar package [%s] failed: %d", u, resp.StatusCode)
|
logging.LogErrorf("get bazaar package [%s] failed: %d", u, resp.StatusCode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue