fix(file2document): batch link should add to existing KBs, not replace them (#17172)

This commit is contained in:
euvre
2026-07-21 19:05:02 +08:00
committed by GitHub
parent 3f5b765a5f
commit 3f9d9529b3
2 changed files with 54 additions and 22 deletions

View File

@@ -559,7 +559,13 @@ func (h *FileHandler) LinkToDatasets(c *gin.Context) {
return
}
if err := h.file2DocumentService.LinkToDatasets(user.ID, &req); err != nil {
mode := strings.ToLower(c.DefaultQuery("mode", "replace"))
if mode != "add" && mode != "replace" {
common.ResponseWithCodeData(c, common.CodeArgumentError, nil, "mode must be 'add' or 'replace'")
return
}
if err := h.file2DocumentService.LinkToDatasets(user.ID, &req, mode); err != nil {
common.ResponseWithCodeData(c, linkToDatasetsErrorCode(err), nil, err.Error())
return
}