fix: Fixed issue where deleting symbolic link files fails (#11373)

Refs https://github.com/1Panel-dev/1Panel/issues/11324
This commit is contained in:
CityFun 2025-12-17 16:44:10 +08:00 committed by GitHub
parent 2546809013
commit 2ad882b7c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -172,7 +172,6 @@ func shouldFilterPath(path string) bool {
return false
}
// 递归构建文件树(只取当前目录以及当前目录下的第一层子节点)
func (f *FileService) buildFileTree(node *response.FileTree, items []*files.FileInfo, op request.FileOption, level int) error {
for _, v := range items {
if shouldFilterPath(v.Path) {
@ -272,6 +271,11 @@ func (f *FileService) Delete(op request.FileDelete) error {
return fo.DeleteFile(op.Path)
}
}
info, _ := fo.Fs.Stat(op.Path)
if info == nil || files.IsSymlink(info.Mode()) {
return os.Remove(op.Path)
}
if err := NewIRecycleBinService().Create(request.RecycleBinCreate{SourcePath: op.Path}); err != nil {
return err
}