Deletes a specific wiki cache from the file system.
(
owner: str = Query(..., description="Repository owner"),
repo: str = Query(..., description="Repository name"),
repo_type: str = Query(..., description="Repository type (e.g., github, gitlab)"),
language: str = Query(..., description="Language of the wiki content"),
authorization_code: Optional[str] = Query(None, description="Authorization code")
)
| 503 | |
| 504 | @app.delete("/api/wiki_cache") |
| 505 | async def delete_wiki_cache( |
| 506 | owner: str = Query(..., description="Repository owner"), |
| 507 | repo: str = Query(..., description="Repository name"), |
| 508 | repo_type: str = Query(..., description="Repository type (e.g., github, gitlab)"), |
| 509 | language: str = Query(..., description="Language of the wiki content"), |
| 510 | authorization_code: Optional[str] = Query(None, description="Authorization code") |
| 511 | ): |
| 512 | """ |
| 513 | Deletes a specific wiki cache from the file system. |
| 514 | """ |
| 515 | # Language validation |
| 516 | supported_langs = configs["lang_config"]["supported_languages"] |
| 517 | if not supported_langs.__contains__(language): |
| 518 | raise HTTPException(status_code=400, detail="Language is not supported") |
| 519 | |
| 520 | if WIKI_AUTH_MODE: |
| 521 | logger.info("check the authorization code") |
| 522 | if not authorization_code or WIKI_AUTH_CODE != authorization_code: |
| 523 | raise HTTPException(status_code=401, detail="Authorization code is invalid") |
| 524 | |
| 525 | logger.info(f"Attempting to delete wiki cache for {owner}/{repo} ({repo_type}), lang: {language}") |
| 526 | cache_path = get_wiki_cache_path(owner, repo, repo_type, language) |
| 527 | |
| 528 | if os.path.exists(cache_path): |
| 529 | try: |
| 530 | os.remove(cache_path) |
| 531 | logger.info(f"Successfully deleted wiki cache: {cache_path}") |
| 532 | return {"message": f"Wiki cache for {owner}/{repo} ({language}) deleted successfully"} |
| 533 | except Exception as e: |
| 534 | logger.error(f"Error deleting wiki cache {cache_path}: {e}") |
| 535 | raise HTTPException(status_code=500, detail=f"Failed to delete wiki cache: {str(e)}") |
| 536 | else: |
| 537 | logger.warning(f"Wiki cache not found, cannot delete: {cache_path}") |
| 538 | raise HTTPException(status_code=404, detail="Wiki cache not found") |
| 539 | |
| 540 | @app.get("/health") |
| 541 | async def health_check(): |
nothing calls this directly
no test coverage detected