From 00e0f6b7decb65cde0675255c9947b36a564b0b5 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 1 Sep 2022 11:53:07 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E6=94=B9=E8=BF=9B=E9=9D=9E=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E7=94=A8=E6=88=B7=E9=9B=86=E5=B8=82=E5=8C=85=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=80=9F=E5=BA=A6=20Fix=20https://github.com/siyuan-n?= =?UTF-8?q?ote/siyuan/issues/5779?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/bazaar/icon.go | 4 ++-- kernel/bazaar/package.go | 11 ++++------- kernel/bazaar/template.go | 4 ++-- kernel/bazaar/theme.go | 4 ++-- kernel/bazaar/widget.go | 4 ++-- kernel/model/bazzar.go | 10 +++++----- kernel/util/path.go | 9 ++++----- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/kernel/bazaar/icon.go b/kernel/bazaar/icon.go index 8a9768c1e..80a156071 100644 --- a/kernel/bazaar/icon.go +++ b/kernel/bazaar/icon.go @@ -127,9 +127,9 @@ func Icons() (icons []*Icon) { return } -func InstallIcon(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error { +func InstallIcon(repoURL, repoHash, installPath string, systemID string) error { repoURLHash := repoURL + "@" + repoHash - data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID) + data, err := downloadPackage(repoURLHash, true, systemID) if nil != err { return err } diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go index dd355a891..12f8b7462 100644 --- a/kernel/bazaar/package.go +++ b/kernel/bazaar/package.go @@ -37,9 +37,9 @@ import ( "golang.org/x/text/transform" ) -func GetPackageREADME(repoURL, repoHash string, chinaCDN bool, systemID string) (ret string) { +func GetPackageREADME(repoURL, repoHash string, systemID string) (ret string) { repoURLHash := repoURL + "@" + repoHash - data, err := downloadPackage(repoURLHash+"/README.md", chinaCDN, false, systemID) + data, err := downloadPackage(repoURLHash+"/README.md", false, systemID) if nil != err { ret = "Load bazaar package's README.md failed: " + err.Error() return @@ -75,14 +75,11 @@ func GetPackageREADME(repoURL, repoHash string, chinaCDN bool, systemID string) return } -func downloadPackage(repoURLHash string, chinaCDN, pushProgress bool, systemID string) (data []byte, err error) { +func downloadPackage(repoURLHash string, pushProgress bool, systemID string) (data []byte, err error) { // repoURLHash: https://github.com/88250/Comfortably-Numb@6286912c381ef3f83e455d06ba4d369c498238dc pushID := repoURLHash[:strings.LastIndex(repoURLHash, "@")] repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/") - u := util.BazaarOSSFileServer + "/package/" + repoURLHash - if chinaCDN { - u = util.BazaarOSSServer + "/package/" + repoURLHash - } + u := util.BazaarOSSServer + "/package/" + repoURLHash buf := &bytes.Buffer{} resp, err := httpclient.NewBrowserDownloadRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) { if pushProgress { diff --git a/kernel/bazaar/template.go b/kernel/bazaar/template.go index fc402897e..c08083264 100644 --- a/kernel/bazaar/template.go +++ b/kernel/bazaar/template.go @@ -130,9 +130,9 @@ func Templates() (templates []*Template) { return } -func InstallTemplate(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error { +func InstallTemplate(repoURL, repoHash, installPath string, systemID string) error { repoURLHash := repoURL + "@" + repoHash - data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID) + data, err := downloadPackage(repoURLHash, true, systemID) if nil != err { return err } diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.go index 25842e7cc..23a2a2ebf 100644 --- a/kernel/bazaar/theme.go +++ b/kernel/bazaar/theme.go @@ -129,9 +129,9 @@ func Themes() (ret []*Theme) { return } -func InstallTheme(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error { +func InstallTheme(repoURL, repoHash, installPath string, systemID string) error { repoURLHash := repoURL + "@" + repoHash - data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID) + data, err := downloadPackage(repoURLHash, true, systemID) if nil != err { return err } diff --git a/kernel/bazaar/widget.go b/kernel/bazaar/widget.go index 93e8d8ab5..db5742e34 100644 --- a/kernel/bazaar/widget.go +++ b/kernel/bazaar/widget.go @@ -128,9 +128,9 @@ func Widgets() (widgets []*Widget) { return } -func InstallWidget(repoURL, repoHash, installPath string, chinaCDN bool, systemID string) error { +func InstallWidget(repoURL, repoHash, installPath string, systemID string) error { repoURLHash := repoURL + "@" + repoHash - data, err := downloadPackage(repoURLHash, chinaCDN, true, systemID) + data, err := downloadPackage(repoURLHash, true, systemID) if nil != err { return err } diff --git a/kernel/model/bazzar.go b/kernel/model/bazzar.go index ca19b4bf1..5dded0c90 100644 --- a/kernel/model/bazzar.go +++ b/kernel/model/bazzar.go @@ -28,7 +28,7 @@ import ( ) func GetPackageREADME(repoURL, repoHash string) (ret string) { - ret = bazaar.GetPackageREADME(repoURL, repoHash, IsSubscriber(), Conf.System.ID) + ret = bazaar.GetPackageREADME(repoURL, repoHash, Conf.System.ID) return } @@ -54,7 +54,7 @@ func InstallBazaarWidget(repoURL, repoHash, widgetName string) error { defer writingDataLock.Unlock() installPath := filepath.Join(util.DataDir, "widgets", widgetName) - err := bazaar.InstallWidget(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID) + err := bazaar.InstallWidget(repoURL, repoHash, installPath, Conf.System.ID) if nil != err { return errors.New(fmt.Sprintf(Conf.Language(46), widgetName)) } @@ -96,7 +96,7 @@ func InstallBazaarIcon(repoURL, repoHash, iconName string) error { defer writingDataLock.Unlock() installPath := filepath.Join(util.IconsPath, iconName) - err := bazaar.InstallIcon(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID) + err := bazaar.InstallIcon(repoURL, repoHash, installPath, Conf.System.ID) if nil != err { return errors.New(fmt.Sprintf(Conf.Language(46), iconName)) } @@ -145,7 +145,7 @@ func InstallBazaarTheme(repoURL, repoHash, themeName string, mode int, update bo closeThemeWatchers() installPath := filepath.Join(util.ThemesPath, themeName) - err := bazaar.InstallTheme(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID) + err := bazaar.InstallTheme(repoURL, repoHash, installPath, Conf.System.ID) if nil != err { return errors.New(fmt.Sprintf(Conf.Language(46), themeName)) } @@ -202,7 +202,7 @@ func InstallBazaarTemplate(repoURL, repoHash, templateName string) error { defer writingDataLock.Unlock() installPath := filepath.Join(util.DataDir, "templates", templateName) - err := bazaar.InstallTemplate(repoURL, repoHash, installPath, IsSubscriber(), Conf.System.ID) + err := bazaar.InstallTemplate(repoURL, repoHash, installPath, Conf.System.ID) if nil != err { return errors.New(fmt.Sprintf(Conf.Language(46), templateName)) } diff --git a/kernel/util/path.go b/kernel/util/path.go index b065c8890..bfdcd09fb 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -34,11 +34,10 @@ var ( ) const ( - ServerPort = "6806" // HTTP/WebSocket 端口 - AliyunServer = "https://siyuan-sync.b3logfile.com" // 云端服务地址,阿里云负载均衡,用于接口,数据同步文件上传、下载会走七牛云 OSS http://siyuan-data.b3logfile.com - BazaarStatServer = "http://bazaar.b3logfile.com" // 集市包统计服务地址,直接对接 Bucket 没有 CDN 缓存 - BazaarOSSServer = "https://oss.b3logfile.com" // 云端对象存储地址,七牛云,仅用于读取小文件(比如配置 json),不用于读取包内容(如果是订阅会员则用于读取包内容) - BazaarOSSFileServer = "https://oss0.b3logfile.com" // 云端对象存储文件服务地址,Cloudflare,用于读取包内容 + ServerPort = "6806" // HTTP/WebSocket 端口 + AliyunServer = "https://siyuan-sync.b3logfile.com" // 云端服务地址,阿里云负载均衡,用于接口,数据同步文件上传、下载会走七牛云 OSS http://siyuan-data.b3logfile.com + BazaarStatServer = "http://bazaar.b3logfile.com" // 集市包统计服务地址,直接对接 Bucket 没有 CDN 缓存 + BazaarOSSServer = "https://oss.b3logfile.com" // 云端对象存储地址,七牛云,仅用于读取集市包 ) func ShortPathForBootingDisplay(p string) string {