.
This commit is contained in:
@@ -81,7 +81,7 @@ def _safe_extract_zip(data: bytes, dest: Path) -> int:
|
||||
return count
|
||||
|
||||
|
||||
def _run_rescan(job_id: str, staging: Path, prefix: str, force: bool):
|
||||
def _run_rescan(job_id: str, staging: Path, prefix: str, force: bool, seed_keywords: str = ""):
|
||||
cfg = _cfg()
|
||||
try:
|
||||
if not cfg["conn"]:
|
||||
@@ -114,6 +114,7 @@ def _run_rescan(job_id: str, staging: Path, prefix: str, force: bool):
|
||||
force=force,
|
||||
purge_missing=False,
|
||||
remote_root=cfg["remote_root"],
|
||||
seed_keywords=seed_keywords,
|
||||
)
|
||||
files = []
|
||||
if isinstance(summary, dict):
|
||||
@@ -208,12 +209,14 @@ async def rescan(
|
||||
file: list[UploadFile] = File(..., description="ZIP, one help file, or several files from a folder"),
|
||||
prefix: str = Form("RIP"),
|
||||
force: str = Form("false"),
|
||||
keywords: str = Form(""),
|
||||
x_rescan_token: Optional[str] = Header(None, alias="X-Rescan-Token"),
|
||||
token: Optional[str] = Form(None),
|
||||
):
|
||||
"""
|
||||
Upload a .zip, one .docx/.html/.pdf/.txt/.doc, or several such files
|
||||
(folder pick). Process on server, write sections to OUTPUT_DIR and Postgres.
|
||||
Optional form field ``keywords``: comma-separated terms prepended to every section.
|
||||
"""
|
||||
_check_token(x_rescan_token or token)
|
||||
|
||||
@@ -232,6 +235,7 @@ async def rescan(
|
||||
|
||||
job_id = uuid.uuid4().hex[:12]
|
||||
force_flag = str(force).lower() in ("1", "true", "yes", "on")
|
||||
seed_keywords = (keywords or "").strip()
|
||||
_set_job(
|
||||
job_id,
|
||||
status="queued",
|
||||
@@ -241,7 +245,7 @@ async def rescan(
|
||||
force=force_flag,
|
||||
created_at=datetime.now(timezone.utc).isoformat(),
|
||||
)
|
||||
background_tasks.add_task(_run_rescan, job_id, staging, prefix, force_flag)
|
||||
background_tasks.add_task(_run_rescan, job_id, staging, prefix, force_flag, seed_keywords)
|
||||
return JSONResponse(
|
||||
{
|
||||
"ok": True,
|
||||
|
||||
Reference in New Issue
Block a user