mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
feat: 解决创建软连接失败的BUG
This commit is contained in:
parent
b27f42df58
commit
bb9c2490c4
@ -93,12 +93,15 @@ func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, er
|
|||||||
func (f FileService) Create(op request.FileCreate) error {
|
func (f FileService) Create(op request.FileCreate) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if fo.Stat(op.Path) {
|
if fo.Stat(op.Path) {
|
||||||
return errors.New("file is exist")
|
return buserr.New(constant.ErrFileIsExit)
|
||||||
}
|
}
|
||||||
if op.IsDir {
|
if op.IsDir {
|
||||||
return fo.CreateDir(op.Path, fs.FileMode(op.Mode))
|
return fo.CreateDir(op.Path, fs.FileMode(op.Mode))
|
||||||
} else {
|
} else {
|
||||||
if op.IsLink {
|
if op.IsLink {
|
||||||
|
if !fo.Stat(op.Path) {
|
||||||
|
return buserr.New(constant.ErrLinkPathNotFound)
|
||||||
|
}
|
||||||
return fo.LinkFile(op.LinkPath, op.Path, op.IsSymlink)
|
return fo.LinkFile(op.LinkPath, op.Path, op.IsSymlink)
|
||||||
} else {
|
} else {
|
||||||
return fo.CreateFile(op.Path)
|
return fo.CreateFile(op.Path)
|
||||||
|
@ -81,6 +81,8 @@ var (
|
|||||||
var (
|
var (
|
||||||
ErrPathNotFound = "ErrPathNotFound"
|
ErrPathNotFound = "ErrPathNotFound"
|
||||||
ErrMovePathFailed = "ErrMovePathFailed"
|
ErrMovePathFailed = "ErrMovePathFailed"
|
||||||
|
ErrLinkPathNotFound = "ErrLinkPathNotFound"
|
||||||
|
ErrFileIsExit = "ErrFileIsExit"
|
||||||
)
|
)
|
||||||
|
|
||||||
//mysql
|
//mysql
|
||||||
|
@ -32,6 +32,8 @@ ErrFileCanNotRead: "File can not read"
|
|||||||
ErrFileToLarge: "file is too large"
|
ErrFileToLarge: "file is too large"
|
||||||
ErrPathNotFound: "Path is not found"
|
ErrPathNotFound: "Path is not found"
|
||||||
ErrMovePathFailed: "The target path cannot contain the original path!"
|
ErrMovePathFailed: "The target path cannot contain the original path!"
|
||||||
|
ErrLinkPathNotFound: "Target path does not exist!"
|
||||||
|
ErrFileIsExit: "File already exists!"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "Domain is already exist"
|
ErrDomainIsExist: "Domain is already exist"
|
||||||
|
@ -32,6 +32,8 @@ ErrFileCanNotRead: "此文件不支持预览"
|
|||||||
ErrFileToLarge: "文件超过10M,无法打开"
|
ErrFileToLarge: "文件超过10M,无法打开"
|
||||||
ErrPathNotFound: "目录不存在"
|
ErrPathNotFound: "目录不存在"
|
||||||
ErrMovePathFailed: "目标路径不能包含原路径!"
|
ErrMovePathFailed: "目标路径不能包含原路径!"
|
||||||
|
ErrLinkPathNotFound: "目标路径不存在!"
|
||||||
|
ErrFileIsExit: "文件已存在!"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "域名已存在"
|
ErrDomainIsExist: "域名已存在"
|
||||||
|
@ -151,7 +151,6 @@ func (w *WriteCounter) SaveProcess() {
|
|||||||
global.LOG.Errorf("save cache error, err %s", err.Error())
|
global.LOG.Errorf("save cache error, err %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileOp) DownloadFileWithProcess(url, dst, key string) error {
|
func (f FileOp) DownloadFileWithProcess(url, dst, key string) error {
|
||||||
@ -183,7 +182,6 @@ func (f FileOp) DownloadFileWithProcess(url, dst, key string) error {
|
|||||||
out.Close()
|
out.Close()
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +203,6 @@ func (f FileOp) DownloadFile(url, dst string) error {
|
|||||||
}
|
}
|
||||||
out.Close()
|
out.Close()
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user