soem fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
@@ -210,18 +210,18 @@ def update_advanced_config(
|
||||
) from e
|
||||
|
||||
|
||||
@router.post("/directory", response_model=Dict[str, str])
|
||||
def update_directory(
|
||||
@router.post("/directory", response_model=Dict[str, Any])
|
||||
async def update_directory(
|
||||
directory_config: Dict[str, str], auth: dict = Depends(require_auth)
|
||||
) -> Dict[str, str]:
|
||||
"""Update anime directory configuration.
|
||||
) -> Dict[str, Any]:
|
||||
"""Update anime directory configuration and run migration.
|
||||
|
||||
Args:
|
||||
directory_config: Dictionary with 'directory' key
|
||||
auth: Authentication token (required)
|
||||
|
||||
Returns:
|
||||
Success message
|
||||
Success message with optional migration results
|
||||
"""
|
||||
try:
|
||||
directory = directory_config.get("directory")
|
||||
@@ -235,13 +235,27 @@ def update_directory(
|
||||
app_config = config_service.load_config()
|
||||
|
||||
# Store directory in other section
|
||||
if "anime_directory" not in app_config.other:
|
||||
app_config.other["anime_directory"] = directory
|
||||
else:
|
||||
app_config.other["anime_directory"] = directory
|
||||
app_config.other["anime_directory"] = directory
|
||||
|
||||
config_service.save_config(app_config)
|
||||
return {"message": "Anime directory updated successfully"}
|
||||
|
||||
# Run migration for the new directory
|
||||
from src.server.services.startup_migration import run_migration_for_directory
|
||||
migration_result = await run_migration_for_directory(directory)
|
||||
|
||||
response: Dict[str, Any] = {
|
||||
"message": "Anime directory updated successfully"
|
||||
}
|
||||
|
||||
if migration_result:
|
||||
response["migration"] = {
|
||||
"total_found": migration_result.total_found,
|
||||
"migrated": migration_result.migrated,
|
||||
"skipped": migration_result.skipped,
|
||||
"failed": migration_result.failed,
|
||||
}
|
||||
|
||||
return response
|
||||
except ConfigServiceError as e:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user