feat: 完成后清理进度文件,并支持迁移数据目录

This commit is contained in:
2026-10-26 09:39:03 +08:00
parent 30a0caeb8d
commit b90b142cbf
13 changed files with 860 additions and 10 deletions
+27
View File
@@ -15,6 +15,7 @@ from fastapi import APIRouter, Body, File, Form, HTTPException, UploadFile
from app.features.download.fields import IDENTITY, NETWORKS, cell_columns, columns_for, grid_spec, meta_groups
from app.features.download.ids import parse_upload
from app.features.download.jobs import _write_ids, app_settings, ensure_output_dir, run_download, store_app_settings
from app.features.download.relocate import current_dir, prepare, resume_moved
from app.features.download.journal import explain_os_error
from app.platform.client import NqiError
from app.platform.constants import CITIES
@@ -62,6 +63,32 @@ def fill_slots() -> None:
_spawn(waiting[0])
@router.get("/data-dir")
async def read_data_dir() -> dict:
state.require_client()
return current_dir()
@router.post("/data-dir/prepare")
async def prepare_data_dir(body: Any = Body(default=None)) -> dict:
state.require_client()
if not isinstance(body, dict):
raise _bad("参数格式不正确")
try:
return await prepare(str(body.get("path") or ""))
except NqiError as exc:
raise _bad(str(exc)) from exc
@router.post("/data-dir/resume")
async def resume_data_dir() -> dict:
state.require_client()
try:
return await resume_moved()
except NqiError as exc:
raise _bad(str(exc)) from exc
@router.get("/settings/app")
async def read_app_settings() -> dict:
return app_settings()