fix(resm): audit physical fulltext files

This commit is contained in:
caoqianming 2026-08-18 14:29:20 +08:00
parent 43e8af74a4
commit b0b26a4ab5
2 changed files with 9 additions and 5 deletions

View File

@ -180,7 +180,8 @@ The paper fetch pipeline in `apps/resm/tasks.py` currently includes:
Title quality is tracked on `Paper` with the original value retained only when a correction Title quality is tracked on `Paper` with the original value retained only when a correction
is applied. `python manage.py audit_paper_titles` performs a dry-run audit by default; is applied. `python manage.py audit_paper_titles` performs a dry-run audit by default;
`--apply` writes only high-confidence XML corrections unless `--allow-medium` is explicitly `--apply` writes only high-confidence XML corrections unless `--allow-medium` is explicitly
provided for reviewed PDF candidates. provided for reviewed PDF candidates. The audit checks physical XML/PDF files even when
legacy `has_fulltext_*` flags are stale.
Download behavior is stateful: Download behavior is stateful:

View File

@ -33,13 +33,16 @@ def _paper_path(paper, ext):
def _fulltext_candidate(paper): def _fulltext_candidate(paper):
candidates = [] candidates = []
if paper.has_fulltext_xml: xml_path = _paper_path(paper, "xml")
candidate = extract_title_from_xml(_paper_path(paper, "xml"), paper.doi) pdf_path = _paper_path(paper, "pdf")
# 历史状态位可能与磁盘不一致;审计以实际文件为准,避免“文件存在但 flag=false”漏检。
if paper.has_fulltext_xml or os.path.isfile(xml_path):
candidate = extract_title_from_xml(xml_path, paper.doi)
if candidate: if candidate:
candidates.append(candidate) candidates.append(candidate)
if paper.has_fulltext_pdf: if paper.has_fulltext_pdf or os.path.isfile(pdf_path):
candidate = extract_title_from_pdf( candidate = extract_title_from_pdf(
_paper_path(paper, "pdf"), paper.doi, paper.first_author or "" pdf_path, paper.doi, paper.first_author or ""
) )
if candidate: if candidate:
candidates.append(candidate) candidates.append(candidate)