mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 22:38:49 +01:00
⚡ 提升桌面端自动更新安装包下载速度 Fix https://github.com/siyuan-note/siyuan/issues/5997
This commit is contained in:
parent
a7de6b8e33
commit
da392ba0d2
4 changed files with 122 additions and 120 deletions
|
|
@ -148,18 +148,13 @@ func downloadInstallPkg(pkgURL, checksum string) {
|
|||
|
||||
logging.LogInfof("downloading install package [%s]", pkgURL)
|
||||
client := req.C().SetTimeout(60 * time.Minute)
|
||||
callback := func(info req.DownloadInfo) {
|
||||
//logging.LogDebugf("downloading install package [%s %.2f%%]", pkgURL, float64(info.DownloadedSize)/float64(info.Response.ContentLength)*100.0)
|
||||
}
|
||||
resp, err := client.R().SetOutputFile(savePath).SetDownloadCallback(callback).Get(pkgURL)
|
||||
err := client.NewParallelDownload(pkgURL).SetConcurrency(8).SetSegmentSize(1024 * 1024 * 4).
|
||||
SetOutputFile(savePath).Do()
|
||||
if nil != err {
|
||||
logging.LogErrorf("download install package failed: %s", err)
|
||||
return
|
||||
}
|
||||
if 200 != resp.StatusCode {
|
||||
logging.LogErrorf("download install package [%s] failed [sc=%d]", pkgURL, resp.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
localChecksum, _ := sha256Hash(savePath)
|
||||
if checksum != localChecksum {
|
||||
logging.LogErrorf("verify checksum failed, download install package [%s] checksum [%s] not equal to downloaded [%s] checksum [%s]", pkgURL, checksum, savePath, localChecksum)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue