🔧 chore: 同步完整后端运行模块
This commit is contained in:
1 parent
d104b9fc8b
commit
2d44699eec
20 files changed
+1465
-235
No files matched your search
+5
-2
@@ -8,7 +8,7 @@ from fastapi import UploadFile, HTTPException
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from apps.base.dependencies import IPRateLimit
|
||||
from apps.base.models import FileCodes
|
||||
from apps.base.models import FileCodes, ShareCodeReservations
|
||||
from core.settings import settings
|
||||
from core.utils import (
|
||||
get_random_num,
|
||||
@@ -43,6 +43,7 @@ async def get_chunk_file_path_name(
|
||||
) -> Tuple[str, str, str, str, str]:
|
||||
today = await get_now()
|
||||
storage_path = settings.storage_path.strip("/")
|
||||
file_name = await sanitize_filename(unquote(file_name or ""))
|
||||
base_path = f"share/data/{today.strftime('%Y/%m/%d')}/{upload_id}"
|
||||
path = f"{storage_path}/{base_path}" if storage_path else base_path
|
||||
prefix, suffix = os.path.splitext(file_name)
|
||||
@@ -122,7 +123,9 @@ async def get_random_code(style: str | None = None) -> str:
|
||||
if code_style == "number"
|
||||
else await get_random_string(CODE_LENGTH)
|
||||
)
|
||||
if not await FileCodes.filter(code=code).exists():
|
||||
if not await FileCodes.filter(code=code).exists() and not await ShareCodeReservations.filter(
|
||||
code=code
|
||||
).exists():
|
||||
return str(code)
|
||||
raise HTTPException(status_code=503, detail="取件码生成暂时繁忙,请重试")
|
||||
|
||||
|
||||
Reference in new issue
Block a user