✨ feat: 完善下载检测与查件生命周期

* 提供有鉴权和并发限制的轻量下载检测,不消耗次数或生成取件事件
* 支持保存检测间隔,并校验关闭选项和有效范围
* 将成功查件记录按时间并入生命周期,与实际发起取件事件区分
* 统一签名下载入口,文本与直链分享仅在下载时计数并保留直链传输
* 处理检测取消时的连接释放,补充鉴权、存储和生命周期集成验证
* 记录文件恢复和测试验收,明确先推送代码再部署测试环境
This commit is contained in:
orion committed 2026-09-19 00:35:56 +08:00
1 parent 32b31ac271
commit 69cfa436de
11 files changed
+555 -39

No files matched your search

+23 -1
View File
@@ -1479,8 +1479,21 @@ class FileService(TrashManagementMixin):
"event_count": download_event_count,
}
)
lookup_stats = await TransferStats.filter(
action="lookup", file_code_id=file_code.id
).order_by("created_at", "id")
events = []
for index, stat in enumerate(lookup_stats, start=1):
events.append({
"key": "queried_event",
"status": "done",
"severity": "info",
"timestamp": stat.created_at,
"value": index,
"detail": stat.ip or "",
})
for index, stat in enumerate(download_stats, start=1):
timeline.append(
events.append(
{
"key": "retrieved_event",
"status": "done",
@@ -1490,6 +1503,7 @@ class FileService(TrashManagementMixin):
"detail": stat.ip or "",
}
)
timeline.extend(sorted(events, key=lambda event: event["timestamp"]))
return timeline
def _seconds_between(
@@ -1710,6 +1724,7 @@ class ConfigService:
"trashRetentionDays",
"enableChunk",
"chunkSizeMB",
"downloadCheckInterval",
"errorCount",
"errorMinute",
"loginCount",
@@ -1748,6 +1763,13 @@ class ConfigService:
if key in settings.default_config and key not in INTERNAL_CONFIG_KEYS
}
if "downloadCheckInterval" in update_data:
interval = update_data["downloadCheckInterval"]
if isinstance(interval, bool) or not isinstance(interval, int) or (
interval != 0 and not 30 <= interval <= 86400
):
raise HTTPException(400, "检测间隔必须是 0(关闭)或 30–86400 秒的整数")
if "chunkSizeMB" in update_data:
raw_size = update_data["chunkSizeMB"]
if isinstance(raw_size, bool) or not (