chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package seafile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"academy/internal/datasource"
|
||||
)
|
||||
|
||||
// knowledgeFileName maps a library file to the knowledge base folder
|
||||
// convention "<library name>/<path inside the library>". Every segment is
|
||||
// sanitized on its own; depth and length limits are applied by the service.
|
||||
func knowledgeFileName(repoName, filePath string) string {
|
||||
segments := strings.Split(strings.TrimPrefix(filePath, "/"), "/")
|
||||
last := len(segments) - 1
|
||||
for i := 0; i < last; i++ {
|
||||
segments[i] = datasource.SanitizeFileName(segments[i])
|
||||
}
|
||||
ext := path.Ext(segments[last])
|
||||
segments[last] = datasource.SanitizeFileName(strings.TrimSuffix(segments[last], ext)) + ext
|
||||
return datasource.SanitizeFileName(repoName) + "/" + strings.Join(segments, "/")
|
||||
}
|
||||
|
||||
func externalID(repoID, filePath string) string {
|
||||
return "seafile:" + repoID + ":" + filePath
|
||||
}
|
||||
|
||||
// fingerprint identifies a file version; three equal parts mean unchanged.
|
||||
func fingerprint(oid string, mtime, size int64) string {
|
||||
return fmt.Sprintf("o:%s|m:%d|s:%d", oid, mtime, size)
|
||||
}
|
||||
|
||||
// validEntryName accepts a single non-empty path segment.
|
||||
func validEntryName(name string) bool {
|
||||
return name != "" && name != "." && name != ".." &&
|
||||
!strings.ContainsAny(name, "/\\") && !strings.ContainsFunc(name, unicode.IsControl)
|
||||
}
|
||||
Reference in new issue
Block a user