mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
调整在线编辑文件
This commit is contained in:
@@ -20,12 +20,13 @@ type GridFs struct {
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
Size int64 `json:"size"`
|
||||
Children []File `json:"children"`
|
||||
Label string `json:"label"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
RelativePath string `json:"relative_path"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
Size int64 `json:"size"`
|
||||
Children []File `json:"children"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
func (f *GridFs) Remove() {
|
||||
|
||||
@@ -708,7 +708,7 @@ func RenameSpiderFile(c *gin.Context) {
|
||||
|
||||
// 原文件路径
|
||||
filePath := path.Join(spider.Src, reqBody.Path)
|
||||
newFilePath := path.Join(spider.Src, reqBody.NewPath)
|
||||
newFilePath := path.Join(path.Join(path.Dir(filePath), reqBody.NewPath))
|
||||
|
||||
// 如果新文件已存在,则报错
|
||||
if utils.Exists(newFilePath) {
|
||||
|
||||
@@ -6,9 +6,14 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetFileNodeTree(dstPath string, level int) (f model.File, err error) {
|
||||
return getFileNodeTree(dstPath, level, dstPath)
|
||||
}
|
||||
|
||||
func getFileNodeTree(dstPath string, level int, rootPath string) (f model.File, err error) {
|
||||
dstF, err := os.Open(dstPath)
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
@@ -24,9 +29,9 @@ func GetFileNodeTree(dstPath string, level int) (f model.File, err error) {
|
||||
}
|
||||
if !fileInfo.IsDir() { //如果dstF是文件
|
||||
return model.File{
|
||||
Label: fileInfo.Name(),
|
||||
Label: fileInfo.Name(),
|
||||
Name: fileInfo.Name(),
|
||||
Path: dstPath,
|
||||
Path: strings.Replace(dstPath, rootPath, "", -1),
|
||||
IsDir: false,
|
||||
Size: fileInfo.Size(),
|
||||
Children: nil,
|
||||
@@ -41,13 +46,13 @@ func GetFileNodeTree(dstPath string, level int) (f model.File, err error) {
|
||||
f = model.File{
|
||||
Label: path.Base(dstPath),
|
||||
Name: path.Base(dstPath),
|
||||
Path: dstPath,
|
||||
Path: strings.Replace(dstPath, rootPath, "", -1),
|
||||
IsDir: true,
|
||||
Size: 0,
|
||||
Children: nil,
|
||||
}
|
||||
for _, subFileInfo := range dir {
|
||||
subFileNode, err := GetFileNodeTree(path.Join(dstPath, subFileInfo.Name()), level+1)
|
||||
subFileNode, err := getFileNodeTree(path.Join(dstPath, subFileInfo.Name()), level+1, rootPath)
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
debug.PrintStack()
|
||||
|
||||
Reference in New Issue
Block a user