fix: 解决开启代理时同步应用失败的问题 (#5298)

This commit is contained in:
ssongliu 2024-06-05 16:04:10 +08:00 committed by GitHub
parent 4883c9dd49
commit 546bc53f28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 29 additions and 2 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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:

View file

@ -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 帳戶資料是否繼續操作',

View file

@ -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 账户数据是否继续操作',

View file

@ -170,7 +170,7 @@
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue';
import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message';
import { MsgError, MsgSuccess } from '@/utils/message';
import { deleteFtp, searchFtp, updateFtp, syncFtp, operateFtp, getFtpBase } from '@/api/modules/toolbox';
import OperateDialog from '@/views/toolbox/ftp/operate/index.vue';
import LogDialog from '@/views/toolbox/ftp/log/index.vue';
@ -262,6 +262,10 @@ const onOperate = async (operation: string) => {
};
const onChangeStatus = async (row: Toolbox.FtpInfo, status: string) => {
if (row.password.length === 0) {
MsgError(i18n.global.t('toolbox.ftp.noPasswdMsg'));
return;
}
ElMessageBox.confirm(i18n.global.t('toolbox.ftp.' + status + 'Helper'), i18n.global.t('cronjob.changeStatus'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),