✨ feat: 整合 2.8.5 后端存储、安全与运行优化
* 禁用 OSS 非必需校验尾部,改用精确会话前缀逐对象清理 * 保护上传终态与分享事务,清理失败保留会话并支持安全重试 * 统一下载响应头,兼容旧下载器并防止文件名注入 * 限流改用单调时钟并限制 IP 记录,缓存模板与静态资源策略 * 统一 ORM 初始化与异常处理,新增查询索引及 SQLite 性能参数 * 固定 uvloop/httptools,统一 Docker keep-alive 与内存回收配置 * 同步版本与升级文档,补充 OSS、清理、缓存及数据库回归验证
This commit is contained in:
1 parent
b2a9aeddb3
commit
41519afb6a
29 files changed
+1033
-132
No files matched your search
@@ -0,0 +1,50 @@
|
||||
"""SQLite 连接 PRAGMA 生效性验证。
|
||||
|
||||
不 mock 配置字典,而是用 get_db_config() 真起一个文件库读取 PRAGMA——
|
||||
Tortoise 的 SqliteClient 在 create_connection() 时逐条执行 credentials 中的
|
||||
PRAGMA,只有真实连接才能验证这一点。
|
||||
"""
|
||||
import pytest
|
||||
from tortoise import Tortoise
|
||||
|
||||
import core.database as database
|
||||
from tests.helpers import close_db
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def file_db(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(database, "_DB_FILE", str(tmp_path / "pragma.db"))
|
||||
if Tortoise._inited:
|
||||
await Tortoise.close_connections()
|
||||
await Tortoise.init(config=database.get_db_config())
|
||||
try:
|
||||
yield Tortoise.get_connection("default")
|
||||
finally:
|
||||
await close_db()
|
||||
|
||||
|
||||
async def _pragma(conn, statement: str):
|
||||
rows = await conn.execute_query_dict(statement)
|
||||
return next(iter(rows[0].values()))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
class TestSqlitePragmas:
|
||||
async def test_wal_and_busy_timeout_kept(self, file_db):
|
||||
assert str(await _pragma(file_db, "PRAGMA journal_mode")).lower() == "wal"
|
||||
assert await _pragma(file_db, "PRAGMA busy_timeout") == 10000
|
||||
|
||||
async def test_synchronous_normal(self, file_db):
|
||||
# 1 = NORMAL(WAL 下省 fsync),2 = FULL
|
||||
assert await _pragma(file_db, "PRAGMA synchronous") == 1
|
||||
|
||||
async def test_temp_store_memory(self, file_db):
|
||||
# 0 = DEFAULT,1 = FILE,2 = MEMORY
|
||||
assert await _pragma(file_db, "PRAGMA temp_store") == 2
|
||||
|
||||
async def test_cache_size_8mb(self, file_db):
|
||||
# 负值单位为 KiB
|
||||
assert await _pragma(file_db, "PRAGMA cache_size") == -8000
|
||||
|
||||
async def test_foreign_keys_on(self, file_db):
|
||||
assert await _pragma(file_db, "PRAGMA foreign_keys") == 1
|
||||
Reference in new issue
Block a user