update
This commit is contained in:
@@ -162,13 +162,7 @@ async def create_blocks(req: BlocksCreateRequest):
|
||||
# Persist the source only the FIRST time; ▶/Resume keeps the existing choice.
|
||||
if not qp.exists():
|
||||
type, location = req.source_type, req.source_location.strip()
|
||||
if type in ("projekt", "uni"):
|
||||
folder = safe_folder(location)
|
||||
if folder is None or not folder.is_dir():
|
||||
raise HTTPException(400, "Folder invalid or not found (path relative to the project root, no ../).")
|
||||
elif type == "link":
|
||||
if not location.lower().startswith(("http://", "https://")):
|
||||
raise HTTPException(400, "Link must start with http:// or https://.")
|
||||
_validate_source(type, location)
|
||||
qp.parent.mkdir(parents=True, exist_ok=True)
|
||||
atomic_write_json(qp, {"type": type, "location": location, "spec": req.instructions.strip()})
|
||||
asyncio.create_task(generate_blocks(topic, req.instructions.strip(), req.provider,
|
||||
@@ -315,14 +309,17 @@ async def reset_block_progress(topic: str, block: str):
|
||||
|
||||
|
||||
def _validate_source(type: str, location: str) -> None:
|
||||
"""Check source input (same rules as on creation)."""
|
||||
"""Check source input (shared by create + edit)."""
|
||||
if type in ("projekt", "uni"):
|
||||
folder = safe_folder(location)
|
||||
if folder is None or not folder.is_dir():
|
||||
raise HTTPException(400, "Folder invalid or not found (path relative to the project root, no ../).")
|
||||
elif type == "link":
|
||||
if not location.lower().startswith(("http://", "https://")):
|
||||
raise HTTPException(400, "Link must start with http:// or https://.")
|
||||
urls = [ln.strip() for ln in location.splitlines() if ln.strip()]
|
||||
if not urls:
|
||||
raise HTTPException(400, "Enter at least one link.")
|
||||
if not all(u.lower().startswith(("http://", "https://")) for u in urls):
|
||||
raise HTTPException(400, "Each link must start with http:// or https:// (one per line).")
|
||||
|
||||
|
||||
@router.get("/blocks/source", response_model=BlocksSourceResponse)
|
||||
|
||||
Reference in New Issue
Block a user