Spaces:
Running
Running
File size: 1,653 Bytes
76b9762 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel, Field
from typing import Optional
from app.service.update.update_service import check_for_updates
from app.utils.helpers import get_current_version
from app.log.logger import get_update_logger
router = APIRouter(prefix="/api/version", tags=["Version"])
logger = get_update_logger()
class VersionInfo(BaseModel):
current_version: str = Field(..., description="ε½εεΊη¨η¨εΊηζ¬")
latest_version: Optional[str] = Field(None, description="ε―η¨ηζζ°ηζ¬")
update_available: bool = Field(False, description="ζ―ε¦ζε―η¨ζ΄ζ°")
error_message: Optional[str] = Field(None, description="ζ£ζ₯ζ΄ζ°ζΆεηηιθ――δΏ‘ζ―")
@router.get("/check", response_model=VersionInfo, summary="ζ£ζ₯εΊη¨η¨εΊζ΄ζ°")
async def get_version_info():
"""
ζ£ζ₯ε½εεΊη¨η¨εΊηζ¬δΈζζ°η GitHub release ηζ¬γ
"""
try:
current_version = get_current_version()
update_available, latest_version, error_message = await check_for_updates()
logger.info(f"Version check API result: current={current_version}, latest={latest_version}, available={update_available}, error='{error_message}'")
return VersionInfo(
current_version=current_version,
latest_version=latest_version,
update_available=update_available,
error_message=error_message
)
except Exception as e:
logger.error(f"Error in /api/version/check endpoint: {e}", exc_info=True)
raise HTTPException(status_code=500, detail="ζ£ζ₯ηζ¬δΏ‘ζ―ζΆεηε
ι¨ιθ――") |