diff --git a/CLAUDE.md b/CLAUDE.md index e6a3451..59ad25e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 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 -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: diff --git a/apps/resm/management/commands/audit_paper_titles.py b/apps/resm/management/commands/audit_paper_titles.py index 0d1fe49..b887c70 100644 --- a/apps/resm/management/commands/audit_paper_titles.py +++ b/apps/resm/management/commands/audit_paper_titles.py @@ -33,13 +33,16 @@ def _paper_path(paper, ext): def _fulltext_candidate(paper): candidates = [] - if paper.has_fulltext_xml: - candidate = extract_title_from_xml(_paper_path(paper, "xml"), paper.doi) + xml_path = _paper_path(paper, "xml") + 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: candidates.append(candidate) - if paper.has_fulltext_pdf: + if paper.has_fulltext_pdf or os.path.isfile(pdf_path): 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: candidates.append(candidate)