mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-27 12:39:01 +08:00
feat:WAF、网站监控增加日志定时清理 (#7057)
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
This commit is contained in:
parent
03e9077c9a
commit
82e15cb3e1
@ -24,7 +24,7 @@ type FileTree struct {
|
||||
}
|
||||
|
||||
type DirSizeRes struct {
|
||||
Size float64 `json:"size" validate:"required"`
|
||||
Size int64 `json:"size" validate:"required"`
|
||||
}
|
||||
|
||||
type FileProcessKeys struct {
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -403,19 +402,6 @@ func (f *FileService) DirSize(req request.DirSizeReq) (response.DirSizeRes, erro
|
||||
if req.Path == "/proc" {
|
||||
return res, nil
|
||||
}
|
||||
cmd := exec.Command("du", "-s", req.Path)
|
||||
output, err := cmd.Output()
|
||||
if err == nil {
|
||||
fields := strings.Fields(string(output))
|
||||
if len(fields) == 2 {
|
||||
var cmdSize int64
|
||||
_, err = fmt.Sscanf(fields[0], "%d", &cmdSize)
|
||||
if err == nil {
|
||||
res.Size = float64(cmdSize * 1024)
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
fo := files.NewFileOp()
|
||||
size, err := fo.GetDirSize(req.Path)
|
||||
if err != nil {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -502,9 +503,22 @@ func (f FileOp) CopyFile(src, dst string) error {
|
||||
return cmd.ExecCmd(fmt.Sprintf(`cp -f '%s' '%s'`, src, dst+"/"))
|
||||
}
|
||||
|
||||
func (f FileOp) GetDirSize(path string) (float64, error) {
|
||||
func (f FileOp) GetDirSize(path string) (int64, error) {
|
||||
duCmd := exec.Command("du", "-s", path)
|
||||
output, err := duCmd.Output()
|
||||
if err == nil {
|
||||
fields := strings.Fields(string(output))
|
||||
if len(fields) == 2 {
|
||||
var cmdSize int64
|
||||
_, err = fmt.Sscanf(fields[0], "%d", &cmdSize)
|
||||
if err == nil {
|
||||
return cmdSize * 1024, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var size int64
|
||||
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||
err = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -516,7 +530,7 @@ func (f FileOp) GetDirSize(path string) (float64, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return float64(size), nil
|
||||
return size, nil
|
||||
}
|
||||
|
||||
func getFormat(cType CompressType) archiver.CompressedArchive {
|
||||
|
@ -127,6 +127,7 @@ html {
|
||||
color: #8f959e;
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.input-error {
|
||||
|
Loading…
Reference in New Issue
Block a user