mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-11 16:00:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adc34aaf75 | ||
|
|
acb0bf2bfd | ||
|
|
88ad8b1b71 | ||
|
|
8660ac6fe5 | ||
|
|
24098e397f | ||
|
|
21f9e4f201 | ||
|
|
f60500791a | ||
|
|
70c0602970 | ||
|
|
adfa021760 | ||
|
|
0e93d7815b |
@@ -340,7 +340,6 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /files/check [post]
|
||||
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"检测文件 [path] 是否存在","formatEN":"Check whether file [path] exists"}
|
||||
func (b *BaseApi) CheckFile(c *gin.Context) {
|
||||
var req request.FilePathCheck
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
|
||||
@@ -14,7 +14,7 @@ type NginxScopeReq struct {
|
||||
|
||||
type NginxConfigUpdate struct {
|
||||
Scope dto.NginxKey `json:"scope"`
|
||||
Operate string `json:"operate" validate:"required;oneof=add update delete"`
|
||||
Operate string `json:"operate" validate:"required,oneof=add update delete"`
|
||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||
Params interface{} `json:"params"`
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ type WebsiteLogReq struct {
|
||||
}
|
||||
|
||||
type WebsiteDefaultUpdate struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
ID uint `json:"id"`
|
||||
}
|
||||
|
||||
type WebsitePHPConfigUpdate struct {
|
||||
|
||||
@@ -27,18 +27,18 @@ type AppInstall struct {
|
||||
}
|
||||
|
||||
func (i *AppInstall) GetPath() string {
|
||||
return path.Join(i.getAppPath(), i.Name)
|
||||
return path.Join(i.GetAppPath(), i.Name)
|
||||
}
|
||||
|
||||
func (i *AppInstall) GetComposePath() string {
|
||||
return path.Join(i.getAppPath(), i.Name, "docker-compose.yml")
|
||||
return path.Join(i.GetAppPath(), i.Name, "docker-compose.yml")
|
||||
}
|
||||
|
||||
func (i *AppInstall) GetEnvPath() string {
|
||||
return path.Join(i.getAppPath(), i.Name, ".env")
|
||||
return path.Join(i.GetAppPath(), i.Name, ".env")
|
||||
}
|
||||
|
||||
func (i *AppInstall) getAppPath() string {
|
||||
func (i *AppInstall) GetAppPath() string {
|
||||
if i.App.Resource == constant.AppResourceLocal {
|
||||
return path.Join(constant.LocalAppInstallDir, strings.TrimPrefix(i.App.Key, constant.AppResourceLocal))
|
||||
} else {
|
||||
|
||||
@@ -225,7 +225,7 @@ func handleAppRecover(install *model.AppInstall, recoverFile string, isRollback
|
||||
_ = fileOp.Rename(appDir, backPath)
|
||||
_ = fileOp.CreateDir(appDir, 0755)
|
||||
|
||||
if err := handleUnTar(tmpPath+"/app.tar.gz", fmt.Sprintf("%s/%s", constant.AppInstallDir, install.App.Key)); err != nil {
|
||||
if err := handleUnTar(tmpPath+"/app.tar.gz", install.GetAppPath()); err != nil {
|
||||
global.LOG.Errorf("handle recover from app.tar.gz failed, err: %v", err)
|
||||
_ = fileOp.DeleteDir(appDir)
|
||||
_ = fileOp.Rename(backPath, appDir)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/gin-contrib/gzip"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/i18n"
|
||||
@@ -19,6 +20,12 @@ import (
|
||||
|
||||
func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
rootRouter.StaticFS("/public", http.FS(web.Favicon))
|
||||
rootRouter.Use(func(c *gin.Context) {
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/assets/") {
|
||||
c.Header("Cache-Control", "max-age=31536000")
|
||||
}
|
||||
c.Next()
|
||||
})
|
||||
rootRouter.GET("/assets/*filepath", func(c *gin.Context) {
|
||||
staticServer := http.FileServer(http.FS(web.Assets))
|
||||
staticServer.ServeHTTP(c.Writer, c.Request)
|
||||
|
||||
@@ -299,7 +299,8 @@ func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error {
|
||||
if cover {
|
||||
coverFlag = "-f"
|
||||
}
|
||||
cmdStr := fmt.Sprintf("mv %s %s %s", coverFlag, p, dstPath)
|
||||
|
||||
cmdStr := fmt.Sprintf(`mv %s "%s" "%s"`, coverFlag, p, dstPath)
|
||||
if err := cmd.ExecCmd(cmdStr); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -362,13 +363,13 @@ func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error {
|
||||
if name != "" && !cover {
|
||||
dstPath = filepath.Join(dst, name)
|
||||
}
|
||||
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dstPath))
|
||||
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dstPath))
|
||||
} else {
|
||||
dstPath := filepath.Join(dst, name)
|
||||
if cover {
|
||||
dstPath = dst
|
||||
}
|
||||
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dstPath))
|
||||
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dstPath))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,11 +382,12 @@ func (f FileOp) CopyDir(src, dst string) error {
|
||||
if err = f.Fs.MkdirAll(dstDir, srcInfo.Mode()); err != nil {
|
||||
return err
|
||||
}
|
||||
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dst+"/"))
|
||||
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dst+"/"))
|
||||
}
|
||||
|
||||
func (f FileOp) CopyFile(src, dst string) error {
|
||||
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dst+"/"))
|
||||
dst = filepath.Clean(dst) + string(filepath.Separator)
|
||||
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dst+"/"))
|
||||
}
|
||||
|
||||
func (f FileOp) GetDirSize(path string) (float64, error) {
|
||||
|
||||
+9
-14
@@ -1,5 +1,5 @@
|
||||
// Code generated by swaggo/swag. DO NOT EDIT.
|
||||
|
||||
// Package docs GENERATED BY SWAG; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
@@ -5160,15 +5160,6 @@ const docTemplate = `{
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [
|
||||
"path"
|
||||
],
|
||||
"formatEN": "Check whether file [path] exists",
|
||||
"formatZH": "检测文件 [path] 是否存在",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -17373,11 +17364,17 @@ const docTemplate = `{
|
||||
"request.NginxConfigUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"operate",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"operate": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"add",
|
||||
"update",
|
||||
"delete"
|
||||
]
|
||||
},
|
||||
"params": {},
|
||||
"scope": {
|
||||
@@ -18195,8 +18192,6 @@ const docTemplate = `{
|
||||
"request.WebsiteProxyConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"cacheTime",
|
||||
"cacheUnit",
|
||||
"id",
|
||||
"match",
|
||||
"modifier",
|
||||
|
||||
@@ -5153,15 +5153,6 @@
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [
|
||||
"path"
|
||||
],
|
||||
"formatEN": "Check whether file [path] exists",
|
||||
"formatZH": "检测文件 [path] 是否存在",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -17366,11 +17357,17 @@
|
||||
"request.NginxConfigUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"operate",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"operate": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"add",
|
||||
"update",
|
||||
"delete"
|
||||
]
|
||||
},
|
||||
"params": {},
|
||||
"scope": {
|
||||
@@ -18188,8 +18185,6 @@
|
||||
"request.WebsiteProxyConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"cacheTime",
|
||||
"cacheUnit",
|
||||
"id",
|
||||
"match",
|
||||
"modifier",
|
||||
|
||||
@@ -3229,6 +3229,10 @@ definitions:
|
||||
request.NginxConfigUpdate:
|
||||
properties:
|
||||
operate:
|
||||
enum:
|
||||
- add
|
||||
- update
|
||||
- delete
|
||||
type: string
|
||||
params: {}
|
||||
scope:
|
||||
@@ -3236,6 +3240,7 @@ definitions:
|
||||
websiteId:
|
||||
type: integer
|
||||
required:
|
||||
- operate
|
||||
- websiteId
|
||||
type: object
|
||||
request.NginxProxyUpdate:
|
||||
@@ -3810,8 +3815,6 @@ definitions:
|
||||
type: string
|
||||
type: object
|
||||
required:
|
||||
- cacheTime
|
||||
- cacheUnit
|
||||
- id
|
||||
- match
|
||||
- modifier
|
||||
@@ -7659,13 +7662,6 @@ paths:
|
||||
summary: Check file exist
|
||||
tags:
|
||||
- File
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys:
|
||||
- path
|
||||
formatEN: Check whether file [path] exists
|
||||
formatZH: 检测文件 [path] 是否存在
|
||||
paramKeys: []
|
||||
/files/chunkdownload:
|
||||
post:
|
||||
consumes:
|
||||
|
||||
@@ -34,11 +34,11 @@ export const ChangeFileMode = (form: File.FileCreate) => {
|
||||
};
|
||||
|
||||
export const CompressFile = (form: File.FileCompress) => {
|
||||
return http.post<File.File>('files/compress', form);
|
||||
return http.post<File.File>('files/compress', form, TimeoutEnum.T_10M);
|
||||
};
|
||||
|
||||
export const DeCompressFile = (form: File.FileDeCompress) => {
|
||||
return http.post<File.File>('files/decompress', form);
|
||||
return http.post<File.File>('files/decompress', form, TimeoutEnum.T_10M);
|
||||
};
|
||||
|
||||
export const GetFileContent = (params: File.ReqFile) => {
|
||||
|
||||
@@ -121,7 +121,7 @@ export const ApplySSL = (req: Website.SSLApply) => {
|
||||
};
|
||||
|
||||
export const RenewSSL = (req: Website.SSLRenew) => {
|
||||
return http.post<any>(`/websites/ssl/renew`, req);
|
||||
return http.post<any>(`/websites/ssl/renew`, req, TimeoutEnum.T_10M);
|
||||
};
|
||||
|
||||
export const UpdateSSL = (req: Website.SSLUpdate) => {
|
||||
@@ -129,7 +129,7 @@ export const UpdateSSL = (req: Website.SSLUpdate) => {
|
||||
};
|
||||
|
||||
export const GetDnsResolve = (req: Website.DNSResolveReq) => {
|
||||
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, TimeoutEnum.T_60S);
|
||||
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, TimeoutEnum.T_5M);
|
||||
};
|
||||
|
||||
export const GetHTTPSConfig = (id: number) => {
|
||||
|
||||
@@ -120,5 +120,5 @@ export const Units = [
|
||||
{ label: i18n.global.t('commons.units.day'), value: 'd' },
|
||||
{ label: i18n.global.t('commons.units.week'), value: 'w' },
|
||||
{ label: i18n.global.t('commons.units.month'), value: 'M' },
|
||||
{ label: i18n.global.t('commons.units.year'), value: 'Y' },
|
||||
{ label: i18n.global.t('commons.units.year'), value: 'y' },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user