P0 - Panic 风险修复: - payment.rs: unwrap() → let-else safe handling - payment.rs: get_jwt_secret() expect → Result/AppError - auth.rs: openid 切片添加 len >= 8 守卫 - main.rs: 启动时 expect → unwrap_or_else 描述性 panic - main.rs: Directive::from_str 添加 fallback P1 - 逻辑/安全修复: - payment.rs: urlencoding() + 解码 bug 修复 (移除 had_escape) - payment.rs: Mock 支付添加 check_mock_payment_allowed 检查 - db.rs: 永久会员 NULL → 2099-12-31 一致化 - user.rs: 维护模式添加安全说明注释 - 自动清理 unused_variables 警告 (_is_mobile) P2 - 错误吞没修复: - main.rs: 3 处定时任务 let _ = → if let Err = tracing::error! - db.rs + admin.rs: 7 处通知/审计日志 let _ = → tracing::warn! - auth.rs: refresh token 保存 add warn 日志 P3 - 死代码清理: - models.rs: 移除 TokenResponse (dead) - models.rs: 移除 AppState 中 5 个未使用字段 (env var 直接读取) - error.rs: 移除 3 个 dead ErrorResponse 方法 - rate_limiter.rs: extract_client_ip_from_header → #[cfg(test)] - models.rs: 注释 typo fix (user_ytpe → user_type) - db.rs: RefreshToken 添加 deserialization 注释 Shell 脚本修复: - deploy.sh: run_migrations 移到 restart_service 之前 - test.sh: 移除 EXIT trap 覆盖; heredoc 引号修复; 维护模式添加 restart - common.sh: mock_key 添加 sed 转义 (防 / & 注入) 验证: cargo check 0 warnings, 8 tests passed
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -230,7 +230,9 @@ async fn main() -> std::io::Result<()> {
|
||||
.timeout(std::time::Duration::from_secs(10))
|
||||
.connect_timeout(std::time::Duration::from_secs(5))
|
||||
.build()
|
||||
.expect("创建 HTTP 客户端失败");
|
||||
.unwrap_or_else(|e| {
|
||||
panic!("创建 HTTP 客户端失败: {}", e);
|
||||
});
|
||||
|
||||
// 启动时清理:过期订单 + 过期登录码
|
||||
match db::cleanup_expired_pending_orders(&pool, None).await {
|
||||
@@ -260,13 +262,19 @@ async fn main() -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
// 会员到期前 7 天提醒
|
||||
let _ = db::check_member_expiry_soon(&pool_clone).await;
|
||||
if let Err(e) = db::check_member_expiry_soon(&pool_clone).await {
|
||||
tracing::error!("检查会员到期失败: {}", e);
|
||||
}
|
||||
|
||||
// 清理超过 24 小时的过期待支付订单
|
||||
let _ = db::cleanup_expired_pending_orders(&pool_clone, None).await;
|
||||
if let Err(e) = db::cleanup_expired_pending_orders(&pool_clone, None).await {
|
||||
tracing::error!("清理过期订单失败: {}", e);
|
||||
}
|
||||
|
||||
// 清理过期的 refresh_token
|
||||
let _ = db::cleanup_expired_refresh_tokens(&pool_clone).await;
|
||||
if let Err(e) = db::cleanup_expired_refresh_tokens(&pool_clone).await {
|
||||
tracing::error!("清理过期 refresh token 失败: {}", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user