splitPathLevels 拆解文件路径为所有父级目录路径 示例:/1/2/3/file.md -> ["/1", "/1/2", "/1/2/3"]
(filePath string)
| 1774 | // splitPathLevels 拆解文件路径为所有父级目录路径 |
| 1775 | // 示例:/1/2/3/file.md -> ["/1", "/1/2", "/1/2/3"] |
| 1776 | func splitPathLevels(filePath string) []string { |
| 1777 | if filePath == "" || filePath == "/" { |
| 1778 | return []string{} |
| 1779 | } |
| 1780 | |
| 1781 | // 移除开头和结尾的斜杠,然后分割 |
| 1782 | cleanPath := strings.Trim(filePath, "/") |
| 1783 | parts := strings.Split(cleanPath, "/") |
| 1784 | |
| 1785 | var levels []string |
| 1786 | // 只处理目录部分,排除文件名 |
| 1787 | for i := 1; i < len(parts); i++ { |
| 1788 | level := "/" + strings.Join(parts[:i], "/") |
| 1789 | levels = append(levels, level) |
| 1790 | } |
| 1791 | |
| 1792 | return levels |
| 1793 | } |
| 1794 | |
| 1795 | // CleanupVectorDataForFile 清理文件的向量数据,可以被独立调用 |
| 1796 | func CleanupVectorDataForFile(eid int64, fileID int64) error { |
no outgoing calls
no test coverage detected