feat:code style

This commit is contained in:
Lan
2025-07-05 00:02:04 +08:00
parent c0984bfb1f
commit bdab5bb375
2 changed files with 2 additions and 12 deletions
+1 -5
View File
@@ -22,10 +22,8 @@ async def get_file_path_name(file: UploadFile) -> Tuple[str, str, str, str, str]
filename = await sanitize_filename(unquote(file.filename))
# 使用 UUID 作为子目录名
base_path = f"share/data/{today.strftime('%Y/%m/%d')}/{file_uuid}"
# 如果设置了存储路径,将其添加到基础路径中
path = f"{storage_path}/{base_path}" if storage_path else base_path
prefix, suffix = os.path.splitext(filename)
# 保持原始文件名
save_path = f"{path}/{filename}"
@@ -43,9 +41,7 @@ async def get_chunk_file_path_name(file_name: str, upload_id: str) -> Tuple[str,
return path, suffix, prefix, file_name, save_path
async def get_expire_info(
expire_value: int, expire_style: str
) -> Tuple[Optional[datetime.datetime], int, int, str]:
async def get_expire_info(expire_value: int, expire_style: str) -> Tuple[Optional[datetime.datetime], int, int, str]:
"""获取过期信息"""
expired_count, used_count = -1, 0
now = datetime.datetime.now()
+1 -7
View File
@@ -64,18 +64,12 @@ async def share_file(
ip: str = Depends(ip_limit["upload"]),
):
await validate_file_size(file, settings.uploadSize)
if expire_style not in settings.expireStyle:
raise HTTPException(status_code=400, detail="过期时间类型错误")
expired_at, expired_count, used_count, code = await get_expire_info(
expire_value, expire_style
)
expired_at, expired_count, used_count, code = await get_expire_info(expire_value, expire_style)
path, suffix, prefix, uuid_file_name, save_path = await get_file_path_name(file)
file_storage: FileStorageInterface = storages[settings.file_storage]()
await file_storage.save_file(file, save_path)
await create_file_code(
code=code,
prefix=prefix,