mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-05 23:57:19 +08:00
feat: Update version handling in config and backup services
This commit is contained in:
@@ -2,7 +2,7 @@ import httpx
|
|||||||
import time
|
import time
|
||||||
from fastapi import APIRouter, Depends, Form
|
from fastapi import APIRouter, Depends, Form
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
from services.config import ConfigCenter
|
from services.config import ConfigCenter, VERSION
|
||||||
from services.auth import get_current_active_user, User, has_users
|
from services.auth import get_current_active_user, User, has_users
|
||||||
from api.response import success
|
from api.response import success
|
||||||
router = APIRouter(prefix="/api/config", tags=["config"])
|
router = APIRouter(prefix="/api/config", tags=["config"])
|
||||||
@@ -38,7 +38,7 @@ async def get_all_config(
|
|||||||
@router.get("/status")
|
@router.get("/status")
|
||||||
async def get_system_status():
|
async def get_system_status():
|
||||||
system_info = {
|
system_info = {
|
||||||
"version": "v1.0.0",
|
"version": VERSION,
|
||||||
"title": await ConfigCenter.get("APP_NAME", "Foxel"),
|
"title": await ConfigCenter.get("APP_NAME", "Foxel"),
|
||||||
"logo": await ConfigCenter.get("APP_LOGO", "/logo.svg"),
|
"logo": await ConfigCenter.get("APP_LOGO", "/logo.svg"),
|
||||||
"is_initialized": await has_users()
|
"is_initialized": await has_users()
|
||||||
@@ -58,7 +58,7 @@ async def get_latest_version():
|
|||||||
if current_time - latest_version_cache["timestamp"] < 3600 and latest_version_cache["data"]:
|
if current_time - latest_version_cache["timestamp"] < 3600 and latest_version_cache["data"]:
|
||||||
return success(latest_version_cache["data"])
|
return success(latest_version_cache["data"])
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=10.0, proxy="http://127.0.0.1:7897") as client:
|
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||||
resp = await client.get(
|
resp = await client.get(
|
||||||
"https://api.github.com/repos/DrizzleTime/Foxel/releases/latest",
|
"https://api.github.com/repos/DrizzleTime/Foxel/releases/latest",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
|
|||||||
+7
-3
@@ -1,4 +1,3 @@
|
|||||||
import json
|
|
||||||
from tortoise.transactions import in_transaction
|
from tortoise.transactions import in_transaction
|
||||||
from models.database import (
|
from models.database import (
|
||||||
StorageAdapter,
|
StorageAdapter,
|
||||||
@@ -8,6 +7,8 @@ from models.database import (
|
|||||||
ShareLink,
|
ShareLink,
|
||||||
Configuration,
|
Configuration,
|
||||||
)
|
)
|
||||||
|
from services.config import VERSION
|
||||||
|
|
||||||
|
|
||||||
class BackupService:
|
class BackupService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -24,10 +25,13 @@ class BackupService:
|
|||||||
configs = await Configuration.all().values()
|
configs = await Configuration.all().values()
|
||||||
|
|
||||||
for share in shares:
|
for share in shares:
|
||||||
share["created_at"] = share["created_at"].isoformat() if share.get("created_at") else None
|
share["created_at"] = share["created_at"].isoformat(
|
||||||
share["expires_at"] = share["expires_at"].isoformat() if share.get("expires_at") else None
|
) if share.get("created_at") else None
|
||||||
|
share["expires_at"] = share["expires_at"].isoformat(
|
||||||
|
) if share.get("expires_at") else None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"version": VERSION,
|
||||||
"storage_adapters": list(adapters),
|
"storage_adapters": list(adapters),
|
||||||
"mounts": list(mounts),
|
"mounts": list(mounts),
|
||||||
"user_accounts": list(users),
|
"user_accounts": list(users),
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ from typing import Any, Optional, Dict
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from models.database import Configuration
|
from models.database import Configuration
|
||||||
load_dotenv(dotenv_path=".env")
|
load_dotenv(dotenv_path=".env")
|
||||||
|
VERSION = "v1.0.0"
|
||||||
|
|
||||||
class ConfigCenter:
|
class ConfigCenter:
|
||||||
_cache: Dict[str, Any] = {}
|
_cache: Dict[str, Any] = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user