(username: str)
| 82 | # Route to handle cleaning the user's workspace |
| 83 | @file_router.post('/clean-cache/{username}') |
| 84 | async def clean_cache(username: str): |
| 85 | try: |
| 86 | # Get or create the user's workspace |
| 87 | user_workspace = get_or_create_workspace(username) |
| 88 | |
| 89 | # Delete all files in the user's workspace |
| 90 | for root, dirs, files in os.walk(user_workspace): |
| 91 | for file in files: |
| 92 | file_path = os.path.join(root, file) |
| 93 | os.remove(file_path) |
| 94 | print(f"Deleted file: {file_path}") |
| 95 | |
| 96 | return JSONResponse(content={"message": "Workspace successfully cleaned"}, status_code=200) |
| 97 | |
| 98 | except Exception as e: |
| 99 | print(f"Error cleaning workspace: {e}") |
| 100 | raise HTTPException(status_code=500, detail=f"Failed to clean workspace: {str(e)}") |
nothing calls this directly
no test coverage detected