fix: 修复截图登录检查逻辑的条件判断错误

问题:attempt > 0 应该是 attempt > 1
- attempt 从 range(1, max_retries + 1) 开始,值为 1, 2, 3
- 原条件 attempt > 0 在 attempt=1 时就为 True
- 导致 elif 分支(首次尝试逻辑)成为死代码

修复:
- 将 attempt > 0 改为 attempt > 1
- 更新注释使其更清晰准确

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 22:16:01 +08:00
parent 072fbcbe18
commit 42609651bd

View File

@@ -252,8 +252,8 @@ def take_screenshot_for_account(
# 智能登录状态检查:只在必要时才刷新登录 # 智能登录状态检查:只在必要时才刷新登录
should_refresh_login = not is_cookie_jar_fresh(cookie_path) should_refresh_login = not is_cookie_jar_fresh(cookie_path)
if should_refresh_login and attempt > 0: if should_refresh_login and attempt > 1:
# 只有在重试时刷新登录,避免重复登录操作 # 重试时刷新登录attempt > 1 表示第2次及以后的尝试
log_to_client("正在刷新登录态...", user_id, account_id) log_to_client("正在刷新登录态...", user_id, account_id)
if not _ensure_login_cookies(account, proxy_config, custom_log): if not _ensure_login_cookies(account, proxy_config, custom_log):
log_to_client("截图登录失败", user_id, account_id) log_to_client("截图登录失败", user_id, account_id)