refactor: migrate cleanup policy configuration

This commit is contained in:
jxxghp
2026-08-22 20:30:51 +08:00
parent 3181c01125
commit 047c88997a
6 changed files with 27 additions and 18 deletions
+6
View File
@@ -150,6 +150,12 @@ class ChainRuntimeConfig:
global_image_cache: bool = False
encoding_detection_performance_mode: bool = False
encoding_detection_min_confidence: float = 0.5
data_cleanup_enable: bool = False
data_cleanup_message_days: Any = 0
data_cleanup_download_history_days: Any = 0
data_cleanup_site_userdata_days: Any = 0
data_cleanup_transfer_history_days: Any = 0
data_cleanup_download_failure_days: Any = 0
download_subtitle: bool = True
music_metadata_to_simplified: bool = True
recognize_plugin_first: bool = False
+8 -13
View File
@@ -9,7 +9,7 @@ from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Any, Callable, ContextManager, Dict, Optional, Protocol
from app.runtime.config import settings
from app.application.configuration import get_chain_runtime_config_snapshot
from app.runtime.log import logger
@@ -329,19 +329,14 @@ class DataCleanupService:
def read_cleanup_policy() -> CleanupPolicy:
"""读取并规范化当前数据清理配置,单次运行期间保持快照一致。"""
config = get_chain_runtime_config_snapshot()
return CleanupPolicy(
enabled=bool(settings.DATA_CLEANUP_ENABLE),
message_days=_normalize_days(settings.DATA_CLEANUP_MESSAGE_DAYS),
download_history_days=_normalize_days(
settings.DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS
),
site_userdata_days=_normalize_days(settings.DATA_CLEANUP_SITE_USERDATA_DAYS),
transfer_history_days=_normalize_days(
settings.DATA_CLEANUP_TRANSFER_HISTORY_DAYS
),
download_failure_days=_normalize_days(
settings.DATA_CLEANUP_DOWNLOAD_FAILURE_DAYS
),
enabled=bool(config.data_cleanup_enable),
message_days=_normalize_days(config.data_cleanup_message_days),
download_history_days=_normalize_days(config.data_cleanup_download_history_days),
site_userdata_days=_normalize_days(config.data_cleanup_site_userdata_days),
transfer_history_days=_normalize_days(config.data_cleanup_transfer_history_days),
download_failure_days=_normalize_days(config.data_cleanup_download_failure_days),
)
+6
View File
@@ -97,6 +97,12 @@ def build_chain_runtime_config(settings: Settings) -> ChainRuntimeConfig:
global_image_cache=settings.GLOBAL_IMAGE_CACHE,
encoding_detection_performance_mode=settings.ENCODING_DETECTION_PERFORMANCE_MODE,
encoding_detection_min_confidence=settings.ENCODING_DETECTION_MIN_CONFIDENCE,
data_cleanup_enable=settings.DATA_CLEANUP_ENABLE,
data_cleanup_message_days=settings.DATA_CLEANUP_MESSAGE_DAYS,
data_cleanup_download_history_days=settings.DATA_CLEANUP_DOWNLOAD_HISTORY_DAYS,
data_cleanup_site_userdata_days=settings.DATA_CLEANUP_SITE_USERDATA_DAYS,
data_cleanup_transfer_history_days=settings.DATA_CLEANUP_TRANSFER_HISTORY_DAYS,
data_cleanup_download_failure_days=settings.DATA_CLEANUP_DOWNLOAD_FAILURE_DAYS,
download_subtitle=settings.DOWNLOAD_SUBTITLE,
music_metadata_to_simplified=settings.MUSIC_METADATA_TO_SIMPLIFIED,
recognize_plugin_first=settings.RECOGNIZE_PLUGIN_FIRST,
@@ -979,6 +979,8 @@ Outbox adapter、DB 装饰器、Base 与 UoWstrict 清单扩大到 37 个源
随后将 `app/application/torrent.py` 的代理和媒体后缀读取迁移到同一快照,canonical 配置债务进一步降至 134 个文件;
下载/种子专项测试与架构门禁通过。
`app/application/rss.py` 的代理和编码检测选项也已迁移到快照,配置债务降至 133 个文件;RSS、Rust 解析和音乐资源专项测试通过。
数据维护策略随后接入同一快照,`app/application/maintenance.py` 的直接配置读取移除,债务降至 132 个文件;
清理服务与 Chain 专项测试通过。
#### ARCH-272:异步阻塞检测
@@ -9,7 +9,7 @@
"root": "app"
},
"settings_imports": {
"count": 133,
"count": 132,
"files": [
"app/adapters/cache/backends.py",
"app/adapters/cache/redis.py",
@@ -47,7 +47,6 @@
"app/agent/tools/impl/send_voice_message.py",
"app/agent/tools/impl/update_agent_task.py",
"app/agent/tools/impl/update_system_settings.py",
"app/application/maintenance.py",
"app/application/security/auth.py",
"app/application/security/passkey.py",
"app/application/security/token.py",
+4 -3
View File
@@ -13,8 +13,8 @@
"runtime_to_db": [],
"workflow_to_db": []
},
"edge_count": 6397,
"edge_sha256": "7d10fe3157a2e2e0de2b8e7caf0edbbbb1c8302a58c9faf78812dba8a19e2d7a",
"edge_count": 6398,
"edge_sha256": "ca0fced68968392288a03d38c2da937cf75e6a9fd2dc3be6dadcb72efdbc462b",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -2536,8 +2536,9 @@
"app.application.image -> app.runtime",
"app.application.image -> app.runtime.cache",
"app.application.image -> app.runtime.log",
"app.application.maintenance -> app.application",
"app.application.maintenance -> app.application.configuration",
"app.application.maintenance -> app.runtime",
"app.application.maintenance -> app.runtime.config",
"app.application.maintenance -> app.runtime.log",
"app.application.mediaserver -> app.application",
"app.application.mediaserver -> app.application.service",