mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-15 02:04:46 +08:00
fix: 限制复制和移动到自身
This commit is contained in:
parent
4992281e36
commit
2904ed0edc
@ -161,7 +161,6 @@ func (f FileService) GetContent(op request.FileOption) (response.FileInfo, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) SaveContent(edit request.FileEdit) error {
|
func (f FileService) SaveContent(edit request.FileEdit) error {
|
||||||
|
|
||||||
info, err := files.NewFileInfo(files.FileOption{
|
info, err := files.NewFileInfo(files.FileOption{
|
||||||
Path: edit.Path,
|
Path: edit.Path,
|
||||||
Expand: false,
|
Expand: false,
|
||||||
@ -190,7 +189,11 @@ func (f FileService) MvFile(m request.FileMove) error {
|
|||||||
if !fo.Stat(m.NewPath) {
|
if !fo.Stat(m.NewPath) {
|
||||||
return buserr.New(constant.ErrPathNotFound)
|
return buserr.New(constant.ErrPathNotFound)
|
||||||
}
|
}
|
||||||
|
for _, path := range m.OldPaths {
|
||||||
|
if path == m.NewPath || strings.Contains(m.NewPath, path) {
|
||||||
|
return buserr.New(constant.ErrMovePathFailed)
|
||||||
|
}
|
||||||
|
}
|
||||||
if m.Type == "cut" {
|
if m.Type == "cut" {
|
||||||
return fo.Cut(m.OldPaths, m.NewPath)
|
return fo.Cut(m.OldPaths, m.NewPath)
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ var (
|
|||||||
//file
|
//file
|
||||||
var (
|
var (
|
||||||
ErrPathNotFound = "ErrPathNotFound"
|
ErrPathNotFound = "ErrPathNotFound"
|
||||||
|
ErrMovePathFailed = "ErrMovePathFailed"
|
||||||
)
|
)
|
||||||
|
|
||||||
//mysql
|
//mysql
|
||||||
|
@ -31,6 +31,7 @@ ErrUpdateBuWebsite: 'The application was updated successfully, but the modificat
|
|||||||
ErrFileCanNotRead: "File can not read"
|
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!"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "Domain is already exist"
|
ErrDomainIsExist: "Domain is already exist"
|
||||||
|
@ -31,6 +31,7 @@ ErrUpdateBuWebsite: '应用更新成功,但是网站配置文件修改失败
|
|||||||
ErrFileCanNotRead: "此文件不支持预览"
|
ErrFileCanNotRead: "此文件不支持预览"
|
||||||
ErrFileToLarge: "文件超过10M,无法打开"
|
ErrFileToLarge: "文件超过10M,无法打开"
|
||||||
ErrPathNotFound: "目录不存在"
|
ErrPathNotFound: "目录不存在"
|
||||||
|
ErrMovePathFailed: "目标路径不能包含原路径!"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "域名已存在"
|
ErrDomainIsExist: "域名已存在"
|
||||||
|
@ -100,6 +100,7 @@ const props = defineProps({
|
|||||||
const em = defineEmits(['choose']);
|
const em = defineEmits(['choose']);
|
||||||
|
|
||||||
const checkFile = (row: any) => {
|
const checkFile = (row: any) => {
|
||||||
|
console.log(row.path);
|
||||||
rowName.value = row.name;
|
rowName.value = row.name;
|
||||||
em('choose', row.path);
|
em('choose', row.path);
|
||||||
popoverVisible.value = false;
|
popoverVisible.value = false;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
label-width="100px"
|
label-width="100px"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
|
@submit.enter.prevent
|
||||||
>
|
>
|
||||||
<el-form-item :label="$t('file.name')" prop="name">
|
<el-form-item :label="$t('file.name')" prop="name">
|
||||||
<el-input v-model="addForm.name" />
|
<el-input v-model="addForm.name" />
|
||||||
|
@ -68,11 +68,11 @@
|
|||||||
@blur="search()"
|
@blur="search()"
|
||||||
:placeholder="$t('file.search')"
|
:placeholder="$t('file.search')"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<!-- <template #prepend>
|
||||||
<el-checkbox :disabled="req.path == '/'" v-model="req.containSub">
|
<el-checkbox :disabled="req.path == '/'" v-model="req.containSub">
|
||||||
{{ $t('file.sub') }}
|
{{ $t('file.sub') }}
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
</template>
|
</template> -->
|
||||||
</el-input>
|
</el-input>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<codemirror
|
<codemirror
|
||||||
style="max-height: 600px; width: 100%"
|
style="height: calc(100vh - 430px); width: 100%"
|
||||||
:autofocus="true"
|
:autofocus="true"
|
||||||
:placeholder="$t('website.noLog')"
|
:placeholder="$t('website.noLog')"
|
||||||
:indent-with-tab="true"
|
:indent-with-tab="true"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user