mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-06 23:51:15 +08:00
Go: add context to storage (#17690)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -563,12 +563,12 @@ func (s *DocumentService) patchDocumentMetadata(ctx context.Context, docID strin
|
||||
func (s *DocumentService) BatchUpdateDocumentMetadatas(
|
||||
ctx context.Context,
|
||||
datasetID string,
|
||||
selector *DocumentMetadataSelector,
|
||||
updates []DocumentMetadataUpdate,
|
||||
deletes []DocumentMetadataDelete,
|
||||
) (*BatchUpdateDocumentMetadatasResponse, common.ErrorCode, error) {
|
||||
selector *MetadataSelector,
|
||||
updates []MetadataUpdate,
|
||||
deletes []MetadataDelete,
|
||||
) (*BatchUpdateMetadatasResponse, common.ErrorCode, error) {
|
||||
if selector == nil {
|
||||
selector = &DocumentMetadataSelector{}
|
||||
selector = &MetadataSelector{}
|
||||
}
|
||||
if code, err := validateBatchUpdateDocumentMetadatasRequest(selector, updates, deletes); err != nil {
|
||||
return nil, code, err
|
||||
@@ -635,7 +635,7 @@ func (s *DocumentService) BatchUpdateDocumentMetadatas(
|
||||
// Early-exit when conditions given but nothing matched.
|
||||
rawConds, _ := selector.MetadataCondition["conditions"]
|
||||
if rawConds != nil && len(targetDocIDs) == 0 {
|
||||
return &BatchUpdateDocumentMetadatasResponse{Updated: 0, MatchedDocs: 0}, common.CodeSuccess, nil
|
||||
return &BatchUpdateMetadatasResponse{Updated: 0, MatchedDocs: 0}, common.CodeSuccess, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,13 +675,13 @@ func (s *DocumentService) BatchUpdateDocumentMetadatas(
|
||||
updated++
|
||||
}
|
||||
|
||||
return &BatchUpdateDocumentMetadatasResponse{Updated: updated, MatchedDocs: len(ids)}, common.CodeSuccess, nil
|
||||
return &BatchUpdateMetadatasResponse{Updated: updated, MatchedDocs: len(ids)}, common.CodeSuccess, nil
|
||||
}
|
||||
|
||||
func validateBatchUpdateDocumentMetadatasRequest(
|
||||
selector *DocumentMetadataSelector,
|
||||
updates []DocumentMetadataUpdate,
|
||||
deletes []DocumentMetadataDelete,
|
||||
selector *MetadataSelector,
|
||||
updates []MetadataUpdate,
|
||||
deletes []MetadataDelete,
|
||||
) (common.ErrorCode, error) {
|
||||
for _, upd := range updates {
|
||||
if strings.TrimSpace(upd.Key) == "" || upd.Value == nil {
|
||||
@@ -778,7 +778,7 @@ func cloneDocumentMetadataValue(v interface{}) interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
func applyDocumentMetadataUpdates(meta map[string]interface{}, updates []DocumentMetadataUpdate) bool {
|
||||
func applyDocumentMetadataUpdates(meta map[string]interface{}, updates []MetadataUpdate) bool {
|
||||
changed := false
|
||||
for _, upd := range updates {
|
||||
key := strings.TrimSpace(upd.Key)
|
||||
@@ -854,7 +854,7 @@ func applyDocumentMetadataUpdates(meta map[string]interface{}, updates []Documen
|
||||
return changed
|
||||
}
|
||||
|
||||
func applyDocumentMetadataDeletes(meta map[string]interface{}, deletes []DocumentMetadataDelete) bool {
|
||||
func applyDocumentMetadataDeletes(meta map[string]interface{}, deletes []MetadataDelete) bool {
|
||||
changed := false
|
||||
for _, del := range deletes {
|
||||
key := strings.TrimSpace(del.Key)
|
||||
|
||||
Reference in New Issue
Block a user