mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-20 04:39:00 +08:00
Fix: correct metadata update behavior (#11919)
### What problem does this PR solve? Correct metadata update behavior. #11912 When update `value` is omitted, the corresponding keys are updated to `"value"` regardless of their current values. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -761,13 +761,19 @@ class DocumentService(CommonService):
|
|||||||
key = upd.get("key")
|
key = upd.get("key")
|
||||||
if not key or key not in meta:
|
if not key or key not in meta:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
new_value = upd.get("value")
|
new_value = upd.get("value")
|
||||||
match_value = upd.get("match", new_value)
|
match_provided = "match" in upd
|
||||||
if isinstance(meta[key], list):
|
if isinstance(meta[key], list):
|
||||||
|
if not match_provided:
|
||||||
|
meta[key] = new_value
|
||||||
|
changed = True
|
||||||
|
else:
|
||||||
|
match_value = upd.get("match")
|
||||||
replaced = False
|
replaced = False
|
||||||
new_list = []
|
new_list = []
|
||||||
for item in meta[key]:
|
for item in meta[key]:
|
||||||
if match_value and _str_equal(item, match_value):
|
if _str_equal(item, match_value):
|
||||||
new_list.append(new_value)
|
new_list.append(new_value)
|
||||||
replaced = True
|
replaced = True
|
||||||
else:
|
else:
|
||||||
@ -776,8 +782,11 @@ class DocumentService(CommonService):
|
|||||||
meta[key] = new_list
|
meta[key] = new_list
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
if not match_value:
|
if not match_provided:
|
||||||
continue
|
meta[key] = new_value
|
||||||
|
changed = True
|
||||||
|
else:
|
||||||
|
match_value = upd.get("match")
|
||||||
if _str_equal(meta[key], match_value):
|
if _str_equal(meta[key], match_value):
|
||||||
meta[key] = new_value
|
meta[key] = new_value
|
||||||
changed = True
|
changed = True
|
||||||
|
|||||||
Reference in New Issue
Block a user