Skip to content

Commit ec372db

Browse files
authored
fix: 删除目录校验是否为禁止删除的目录 (#7031)
1 parent 0b87025 commit ec372db

File tree

2 files changed

+9
-7
lines changed
  • backend/app/service
  • frontend/src/views/host/file-management/delete

2 files changed

+9
-7
lines changed

backend/app/service/file.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ func (f *FileService) Create(op request.FileCreate) error {
211211
}
212212

213213
func (f *FileService) Delete(op request.FileDelete) error {
214-
excludeDir := global.CONF.System.DataDir
215-
if strings.Contains(op.Path, ".1panel_clash") || op.Path == excludeDir {
216-
return buserr.New(constant.ErrPathNotDelete)
214+
if op.IsDir {
215+
excludeDir := global.CONF.System.DataDir
216+
if strings.Contains(op.Path, ".1panel_clash") || op.Path == excludeDir {
217+
return buserr.New(constant.ErrPathNotDelete)
218+
}
217219
}
218220
fo := files.NewFileOp()
219221
recycleBinStatus, _ := settingRepo.Get(settingRepo.WithByKey("FileRecycleBin"))

frontend/src/views/host/file-management/delete/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ const getStatus = async () => {
8989
const onConfirm = async () => {
9090
const pros = [];
9191
for (const s of files.value) {
92-
if (s['path'].indexOf('.1panel_clash') > -1) {
93-
MsgWarning(i18n.global.t('file.clashDeleteAlert'));
94-
return;
95-
}
9692
if (s['isDir']) {
93+
if (s['path'].indexOf('.1panel_clash') > -1) {
94+
MsgWarning(i18n.global.t('file.clashDeleteAlert'));
95+
return;
96+
}
9797
const pathRes = await loadBaseDir();
9898
if (s['path'] === pathRes.data) {
9999
MsgWarning(i18n.global.t('file.panelInstallDir'));

0 commit comments

Comments
 (0)