1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-14 01:34:47 +08:00

fix: 限制复制和移动到自身

This commit is contained in:
zhengkunwang223 2023-03-10 11:44:58 +08:00 committed by zhengkunwang223
parent 4992281e36
commit 2904ed0edc
8 changed files with 14 additions and 6 deletions

View File

@ -161,7 +161,6 @@ func (f FileService) GetContent(op request.FileOption) (response.FileInfo, error
}
func (f FileService) SaveContent(edit request.FileEdit) error {
info, err := files.NewFileInfo(files.FileOption{
Path: edit.Path,
Expand: false,
@ -190,7 +189,11 @@ func (f FileService) MvFile(m request.FileMove) error {
if !fo.Stat(m.NewPath) {
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" {
return fo.Cut(m.OldPaths, m.NewPath)
}

View File

@ -79,7 +79,8 @@ var (
//file
var (
ErrPathNotFound = "ErrPathNotFound"
ErrPathNotFound = "ErrPathNotFound"
ErrMovePathFailed = "ErrMovePathFailed"
)
//mysql

View File

@ -31,6 +31,7 @@ ErrUpdateBuWebsite: 'The application was updated successfully, but the modificat
ErrFileCanNotRead: "File can not read"
ErrFileToLarge: "file is too large"
ErrPathNotFound: "Path is not found"
ErrMovePathFailed: "The target path cannot contain the original path!"
#website
ErrDomainIsExist: "Domain is already exist"

View File

@ -31,6 +31,7 @@ ErrUpdateBuWebsite: '应用更新成功,但是网站配置文件修改失败
ErrFileCanNotRead: "此文件不支持预览"
ErrFileToLarge: "文件超过10M,无法打开"
ErrPathNotFound: "目录不存在"
ErrMovePathFailed: "目标路径不能包含原路径!"
#website
ErrDomainIsExist: "域名已存在"

View File

@ -100,6 +100,7 @@ const props = defineProps({
const em = defineEmits(['choose']);
const checkFile = (row: any) => {
console.log(row.path);
rowName.value = row.name;
em('choose', row.path);
popoverVisible.value = false;

View File

@ -19,6 +19,7 @@
label-width="100px"
:rules="rules"
v-loading="loading"
@submit.enter.prevent
>
<el-form-item :label="$t('file.name')" prop="name">
<el-input v-model="addForm.name" />

View File

@ -68,11 +68,11 @@
@blur="search()"
:placeholder="$t('file.search')"
>
<template #prepend>
<!-- <template #prepend>
<el-checkbox :disabled="req.path == '/'" v-model="req.containSub">
{{ $t('file.sub') }}
</el-checkbox>
</template>
</template> -->
</el-input>
</div>
</template>

View File

@ -20,7 +20,7 @@
</div>
<br />
<codemirror
style="max-height: 600px; width: 100%"
style="height: calc(100vh - 430px); width: 100%"
:autofocus="true"
:placeholder="$t('website.noLog')"
:indent-with-tab="true"