mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 14:28:49 +01:00
♻️ 重构内核代理设置 Fix https://github.com/siyuan-note/siyuan/issues/5380
This commit is contained in:
parent
2880222bc6
commit
70b8a7d8eb
16 changed files with 89 additions and 93 deletions
|
|
@ -41,7 +41,7 @@ import (
|
|||
|
||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
|
||||
var resp *req.Response
|
||||
if Conf.Sync.UseDataRepo {
|
||||
|
|
@ -82,7 +82,7 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
|||
|
||||
func removeCloudDirPath(dirPath string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"dirPath": dirPath, "token": Conf.User.UserToken}).
|
||||
|
|
@ -107,7 +107,7 @@ func removeCloudDirPath(dirPath string) (err error) {
|
|||
|
||||
func createCloudSyncDirOSS(name string) (err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"name": name, "token": Conf.User.UserToken}).
|
||||
|
|
@ -138,7 +138,7 @@ func createCloudSyncDirOSS(name string) (err error) {
|
|||
|
||||
func listCloudSyncDirOSS() (dirs []map[string]interface{}, size int64, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken}).
|
||||
SetResult(&result).
|
||||
|
|
@ -290,7 +290,7 @@ func ossDownload0(localDirPath, cloudDirPath, fetch string, fetchedFiles *int, t
|
|||
localFilePath := filepath.Join(localDirPath, fetch)
|
||||
remoteFileURL := path.Join(cloudDirPath, fetch)
|
||||
var result map[string]interface{}
|
||||
resp, err := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String()).
|
||||
resp, err := httpclient.NewCloudRequest().
|
||||
SetResult(&result).
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken, "path": remoteFileURL}).
|
||||
Post(util.AliyunServer + "/apis/siyuan/data/getSiYuanFile?uid=" + Conf.User.UserId)
|
||||
|
|
@ -325,9 +325,9 @@ func ossDownload0(localDirPath, cloudDirPath, fetch string, fetchedFiles *int, t
|
|||
os.Remove(localFilePath)
|
||||
|
||||
if bootORExit {
|
||||
resp, err = httpclient.NewCloudFileRequest15s(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest15s().Get(downloadURL)
|
||||
} else {
|
||||
resp, err = httpclient.NewCloudFileRequest2m(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest2m().Get(downloadURL)
|
||||
}
|
||||
if nil != err {
|
||||
util.LogErrorf("download request [%s] failed: %s", downloadURL, err)
|
||||
|
|
@ -470,7 +470,7 @@ func ossRemove0(cloudDirPath string, removes []string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetBody(map[string]interface{}{"token": Conf.User.UserToken, "dirPath": cloudDirPath, "paths": removes}).
|
||||
Post(util.AliyunServer + "/apis/siyuan/data/removeSiYuanFile?uid=" + Conf.User.UserId)
|
||||
|
|
@ -524,7 +524,7 @@ func getOssUploadToken(filename, cloudDirPath string, length int64) (ret string,
|
|||
// 因为需要指定 key,所以每次上传文件都必须在云端生成 Token,否则有安全隐患
|
||||
|
||||
var result map[string]interface{}
|
||||
req := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String()).
|
||||
req := httpclient.NewCloudRequest().
|
||||
SetResult(&result)
|
||||
req.SetBody(map[string]interface{}{
|
||||
"token": Conf.User.UserToken,
|
||||
|
|
@ -564,7 +564,7 @@ func getOssUploadToken(filename, cloudDirPath string, length int64) (ret string,
|
|||
func getCloudSyncVer(cloudDir string) (cloudSyncVer int64, err error) {
|
||||
start := time.Now()
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"syncDir": cloudDir, "token": Conf.User.UserToken}).
|
||||
|
|
@ -604,7 +604,7 @@ func getCloudSyncVer(cloudDir string) (cloudSyncVer int64, err error) {
|
|||
func getCloudSync(cloudDir string) (assetSize, backupSize int64, device string, err error) {
|
||||
start := time.Now()
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"syncDir": cloudDir, "token": Conf.User.UserToken}).
|
||||
|
|
@ -669,7 +669,7 @@ func getLocalFileListOSS(isBackup bool) (ret map[string]*CloudIndex, err error)
|
|||
|
||||
func getCloudFileListOSS(cloudDirPath string) (ret map[string]*CloudIndex, err error) {
|
||||
result := map[string]interface{}{}
|
||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||
request := httpclient.NewCloudRequest()
|
||||
resp, err := request.
|
||||
SetResult(&result).
|
||||
SetBody(map[string]string{"dirPath": cloudDirPath, "token": Conf.User.UserToken}).
|
||||
|
|
@ -694,7 +694,7 @@ func getCloudFileListOSS(cloudDirPath string) (ret map[string]*CloudIndex, err e
|
|||
|
||||
retData := result["data"].(map[string]interface{})
|
||||
downloadURL := retData["url"].(string)
|
||||
resp, err = httpclient.NewCloudFileRequest15s(Conf.System.NetworkProxy.String()).Get(downloadURL)
|
||||
resp, err = httpclient.NewCloudFileRequest15s().Get(downloadURL)
|
||||
if nil != err {
|
||||
util.LogErrorf("download request [%s] failed: %s", downloadURL, err)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue