Skip to content

PRINTFILM: AI short-video marketing and AI short-drama creation platform

fix(oss): 后台改密钥后清空 Bucket 缓存,避免继续用已禁用 AccessKey

yi221dc7d47204
diff --git a/backend/app/config.py b/backend/app/config.py
index 48c5651..c3509d0 100644
--- a/backend/app/config.py
+++ b/backend/app/config.py
@@ -199,4 +199,10 @@ def get_settings() -> Settings:
def reload_settings() -> Settings:
get_settings.cache_clear()
+ try:
+ from app.services.oss import reset_oss_client
+
+ reset_oss_client()
+ except Exception: # noqa: BLE001
+ pass
return get_settings()
diff --git a/backend/app/services/oss.py b/backend/app/services/oss.py
index 57c8421..2fa1b4b 100644
--- a/backend/app/services/oss.py
+++ b/backend/app/services/oss.py
@@ -33,6 +33,11 @@ def _bucket():
return oss2.Bucket(auth, endpoint, s.oss_bucket)
+def reset_oss_client() -> None:
+ """后台改 OSS 密钥后丢掉缓存的 Bucket,避免继续用已禁用的旧 Key。"""
+ _bucket.cache_clear()
+
+
def oss_enabled() -> bool:
s = get_settings()
return bool(
diff --git a/docs/releases/2026-09-11.md b/docs/releases/2026-09-11.md
index 1940dd2..c8cd990 100644
--- a/docs/releases/2026-09-11.md
+++ b/docs/releases/2026-09-11.md
@@ -1,3 +1,16 @@
+## 2026-09-11 13:40 · OSS 仍用已禁用旧 Key(热修)
+
+- **操作者**:Agent
+- **方式**:SSH 热修(`oss.py` + `config.py`)+ `systemctl restart ai-movie-api`
+- **范围**:api
+- **变更摘要**:
+ - 根因:后台「存储」密钥写在数据库 overlay,且 `_bucket()` 有进程内缓存;改 Key 后仍继续用已禁用的旧 AccessKeyId
+ - 保存设置时清空 OSS 客户端缓存;重启 API 使新 Key 生效
+- **验证**:
+ - [x] health 200
+ - [x] 线上 OSS 客户端 list `kepu/` 成功;生效 AccessKey 已不是报错里那把禁用 Key
+- **提交**:热修后本地提交
+
## 2026-09-11 11:00 · main 全量 + 轮换 OSS Key
- **操作者**:Agent
diff --git a/docs/releases/README.md b/docs/releases/README.md
index 4a51d55..2981493 100644
--- a/docs/releases/README.md
+++ b/docs/releases/README.md
@@ -33,6 +33,7 @@
| 日期 | 摘要 | 文件 |
|------|------|------|
+| 2026-09-11 | OSS 缓存仍用已禁用旧 Key;杭州热修 | [2026-09-11.md](./2026-09-11.md) |
| 2026-09-11 | main 全量 + 轮换 OSS Key;杭州 | [2026-09-11.md](./2026-09-11.md) |
| 2026-09-09 | Seedream 文本审核软化;杭州热修 | [2026-09-09.md](./2026-09-09.md) |
| 2026-09-09 | 角色/场景/道具设定板前缀;杭州热修 | [2026-09-09.md](./2026-09-09.md) |