MCPcopy Create free account
hub / github.com/53AI/53AIHub / DeleteFile

Function DeleteFile

api/model/file.go:971–996  ·  view source on GitHub ↗
(eid int64, id int64)

Source from the content-addressed store, hash-verified

969}
970
971func DeleteFile(eid int64, id int64) error {
972 file, err := GetFileByID(eid, id)
973 if err != nil {
974 return err
975 }
976
977 hasChildren, err := CheckHasChildren(eid, id)
978 if err != nil {
979 return err
980 }
981 if hasChildren {
982 // 如果是包含子项的目录,递归删除所有子项
983 if err := deleteDirectoryWithChildren(eid, id); err != nil {
984 return err
985 }
986 invalidateLibraryFileCountCache(eid, file.LibraryID)
987 return nil
988 }
989
990 // 使用新的级联删除逻辑
991 if err := deleteFileWithCascade(eid, id); err != nil {
992 return err
993 }
994 invalidateLibraryFileCountCache(eid, file.LibraryID)
995 return nil
996}
997
998// deleteDirectoryWithChildren 递归删除目录及其所有子项
999func deleteDirectoryWithChildren(eid int64, id int64) error {

Callers 1

DeleteLibraryFunction · 0.70

Calls 5

GetFileByIDFunction · 0.85
CheckHasChildrenFunction · 0.85
deleteFileWithCascadeFunction · 0.85

Tested by

no test coverage detected