fix: 缩略图上传失败(upload_to_oss str/Path 类型不匹配)
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 25s
AI Code Review / AI Code Review (pull_request) Failing after 41s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1m1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 35s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 3m42s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 3m6s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 4m40s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m36s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 7m24s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 8s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 25s
AI Code Review / AI Code Review (pull_request) Failing after 41s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1m1s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 35s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 3m42s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 3m6s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 4m40s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m36s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 7m24s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 8s
thumbnail_generator.py 等调用方传 str 类型路径,upload_to_oss 函数签名 写的是 Path,导致 local_path.stat() 报 AttributeError,缩略图上传失败 返回 None,异常被吞掉不影响主流程但封面一直是默认图。 修复:函数入参兼容 Path | str,入口处统一转 Path 对象。 其他传 Path 的调用方无副作用。
This commit is contained in:
@@ -142,19 +142,20 @@ def _download_via_http(url: str, local_path: Path) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def upload_to_oss(local_path: Path, storage_key: str) -> str | None:
|
||||
def upload_to_oss(local_path: Path | str, storage_key: str) -> str | None:
|
||||
"""上传文件到 OSS,返回公开 URL。
|
||||
|
||||
大文件(>100MB)自动走分片上传,降低内存峰值,减少 OOM 风险。
|
||||
上传加总超时保护(默认 300s),防止网络异常时无限挂死。
|
||||
|
||||
Args:
|
||||
local_path: 本地文件路径
|
||||
local_path: 本地文件路径(Path 或 str 均可)
|
||||
storage_key: 目标存储键
|
||||
|
||||
Returns:
|
||||
公开访问 URL,上传失败或 OSS 未配置时返回 None。
|
||||
"""
|
||||
local_path = Path(local_path) # 统一转 Path,兼容 str 调用
|
||||
bucket = oss_bucket()
|
||||
if bucket is None:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user