mirror of https://github.com/1Panel-dev/1Panel
fix: 解决开启代理时同步应用失败的问题 (#5298)
parent
4883c9dd49
commit
546bc53f28
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 帳戶資料,是否繼續操作?',
|
||||
|
|
|
@ -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 账户数据,是否继续操作?',
|
||||
|
|
|
@ -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'),
|
||||
|
|
Loading…
Reference in New Issue