diff --git a/backend/app/service/file.go b/backend/app/service/file.go index f8f17b070..1d5b739b1 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -211,9 +211,11 @@ func (f *FileService) Create(op request.FileCreate) error { } func (f *FileService) Delete(op request.FileDelete) error { - excludeDir := global.CONF.System.DataDir - if strings.Contains(op.Path, ".1panel_clash") || op.Path == excludeDir { - return buserr.New(constant.ErrPathNotDelete) + if op.IsDir { + excludeDir := global.CONF.System.DataDir + if strings.Contains(op.Path, ".1panel_clash") || op.Path == excludeDir { + return buserr.New(constant.ErrPathNotDelete) + } } fo := files.NewFileOp() recycleBinStatus, _ := settingRepo.Get(settingRepo.WithByKey("FileRecycleBin")) diff --git a/frontend/src/views/host/file-management/delete/index.vue b/frontend/src/views/host/file-management/delete/index.vue index 00fda9a22..1ed065997 100644 --- a/frontend/src/views/host/file-management/delete/index.vue +++ b/frontend/src/views/host/file-management/delete/index.vue @@ -89,11 +89,11 @@ const getStatus = async () => { const onConfirm = async () => { const pros = []; for (const s of files.value) { - if (s['path'].indexOf('.1panel_clash') > -1) { - MsgWarning(i18n.global.t('file.clashDeleteAlert')); - return; - } if (s['isDir']) { + if (s['path'].indexOf('.1panel_clash') > -1) { + MsgWarning(i18n.global.t('file.clashDeleteAlert')); + return; + } const pathRes = await loadBaseDir(); if (s['path'] === pathRes.data) { MsgWarning(i18n.global.t('file.panelInstallDir'));