mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
fix: whitelist parser metadata to its documented fields before storing
The unfiltered metadata spread let a custom parser overwrite managed columns — stashing 'file_path' in metadata silently repointed the stored row at the user's original file, which delete_document would then unlink. ParsedDocument documents page_count/line_count as the only persisted metadata; merge exactly those.
This commit is contained in:
parent
a11493502f
commit
ad7f152ea7
1 changed files with 4 additions and 1 deletions
|
|
@ -128,13 +128,16 @@ class LocalBackend:
|
|||
**({"images": n.images} if n.images else {})}
|
||||
for n in parsed.nodes if n.content]
|
||||
|
||||
meta = parsed.metadata or {}
|
||||
self._storage.save_document(collection, doc_id, {
|
||||
"doc_name": parsed.doc_name,
|
||||
"doc_description": result.get("doc_description", ""),
|
||||
"file_path": str(managed_path),
|
||||
"file_hash": file_hash,
|
||||
"doc_type": ext.lstrip("."),
|
||||
**(parsed.metadata or {}), # parser-reported, e.g. page_count / line_count
|
||||
# Only the documented parser metadata fields — anything else a
|
||||
# parser reports must not reach (or overwrite) storage columns.
|
||||
**{k: meta[k] for k in ("page_count", "line_count") if k in meta},
|
||||
"structure": result["structure"],
|
||||
"pages": pages,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue