From 546bc53f282ee202b333209d21017d678174f479 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:04:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E6=97=B6=E5=90=8C=E6=AD=A5=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#5298)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 2 +- backend/utils/files/file_op.go | 20 ++++++++++++++++++++ frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + frontend/src/views/toolbox/ftp/index.vue | 6 +++++- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index 8bafd3867..ec91b7771 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -764,7 +764,7 @@ func getAppFromRepo(downloadPath string) error { global.LOG.Infof("[AppStore] download file from %s", downloadUrl) fileOp := files.NewFileOp() packagePath := filepath.Join(constant.ResourceDir, filepath.Base(downloadUrl)) - if err := fileOp.DownloadFile(downloadUrl, packagePath); err != nil { + if err := fileOp.DownloadFileWithProxy(downloadUrl, packagePath); err != nil { return err } if err := fileOp.Decompress(packagePath, constant.ResourceDir, files.SdkZip, ""); err != nil { diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index c97ca0690..2595c2a32 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -3,6 +3,7 @@ package files import ( "archive/zip" "bufio" + "bytes" "context" "crypto/tls" "encoding/json" @@ -327,6 +328,25 @@ func (f FileOp) DownloadFile(url, dst string) error { return nil } +func (f FileOp) DownloadFileWithProxy(url, dst string) error { + _, resp, err := http2.HandleGet(url, http.MethodGet) + if err != nil { + return err + } + + out, err := os.Create(dst) + if err != nil { + return fmt.Errorf("create download file [%s] error, err %s", dst, err.Error()) + } + defer out.Close() + + reader := bytes.NewReader(resp) + if _, err = io.Copy(out, reader); err != nil { + return fmt.Errorf("save download file [%s] error, err %s", dst, err.Error()) + } + return nil +} + func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error { for _, p := range oldPaths { var dstPath string diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 69dc3512b..3692a66f0 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1043,6 +1043,7 @@ const message = { ftp: 'FTP Account', noFtp: 'FTP (pure-ftpd) service not detected, please refer to the official documentation for installation!', operation: 'Perform [{0}] operation on FTP service, continue?', + noPasswdMsg: 'Can not get the current FTP account password, please set the password and try again! ', enableHelper: 'Enabling the selected FTP account will restore its access permissions. Do you want to continue?', disableHelper: diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 992ddd9ea..84efca355 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -988,6 +988,7 @@ const message = { ftp: 'FTP 帳戶', noFtp: '未檢測到 FTP (pure-ftpd) 服務,請參考官方文檔進行安裝!', operation: '對 FTP 服務進行 [{0}] 操作,是否繼續?', + noPasswdMsg: '無法獲取當前 FTP 賬號密碼,請先設置密碼後重試!', enableHelper: '啟用選取的 FTP 帳號後,該 FTP 帳號將恢復訪問權限,是否繼續操作?', disableHelper: '停用選取的 FTP 帳號後,該 FTP 帳號將失去訪問權限,是否繼續操作?', syncHelper: '同步伺服器與資料庫中的 FTP 帳戶資料,是否繼續操作?', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 15185798c..5f8caff2d 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -989,6 +989,7 @@ const message = { ftp: 'FTP 账户', noFtp: '未检测到 FTP (pure-ftpd) 服务,请参考官方文档进行安装!', operation: '对 FTP 服务进行 [{0}] 操作,是否继续?', + noPasswdMsg: '无法获取当前 FTP 账号密码,请先设置密码后重试!', enableHelper: '启用选中的 FTP 账号后,该 FTP 账号恢复访问权限,是否继续操作?', disableHelper: '停用选中的 FTP 账号后,该 FTP 账号将失去访问权限,是否继续操作?', syncHelper: '同步服务器与数据库中的 FTP 账户数据,是否继续操作?', diff --git a/frontend/src/views/toolbox/ftp/index.vue b/frontend/src/views/toolbox/ftp/index.vue index 62363016c..7f3a2ec46 100644 --- a/frontend/src/views/toolbox/ftp/index.vue +++ b/frontend/src/views/toolbox/ftp/index.vue @@ -170,7 +170,7 @@