Skip to content

Commit

Permalink
fix: 删除目录校验是否为禁止删除的目录 (#7031)
Browse files Browse the repository at this point in the history
  • Loading branch information
lan-yonghui authored Nov 13, 2024
1 parent 0b87025 commit ec372db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions backend/app/service/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/host/file-management/delete/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit ec372db

Please sign in to comment.