fix: 修复等待逻辑,避免未完成就滚动导致漏下载

问题:旧逻辑等30秒就超时,重试点击一次后再等30秒就滚动。
大文件30秒下不完,队列满时重试点击无效,导致卡片漏下载。

修复:
- max_wait_per_round 从30秒增加到120秒
- 等待逻辑改为三轮:先等120s→再等120s→重试点击→再等120s
- 总最长等待6分钟,足够6个小文件全部下载完
- 队列满时不立即重试点击,先让正在下载的完成腾出位置
This commit is contained in:
yuming
2026-09-18 21:22:44 +08:00
parent 2e01d9e774
commit 317bd3020d
+29 -18
View File
@@ -544,7 +544,7 @@ def get_remote_new_file_count(baseline_files):
return len(all_files - baseline_files)
def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_round=30):
def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_round=120):
"""循环:点击固定网格 9 个卡片(点击即下载)→ 轮询确认下载数量稳定 → 滚动 2 行。
新版 UI(7.8.1)自绘,dump 拿不到缩略图 bounds,改用固定网格坐标 THUMB_X x THUMB_Y。
首次点击卡片会弹"使用手机网络下载将消耗流量"确认框,点确定后补点一次该卡片。
@@ -747,29 +747,40 @@ def tap_all_thumbnails(baseline, max_rounds=300, poll_interval=4, max_wait_per_r
done = len(tapped_cells) - len(pending)
total = get_remote_new_file_count(baseline)
if pending:
# 超时未打勾的卡片,先重试点击一次:可能是点击落在卡片间隙/分组标签上
# 没生效(下载根本没触发),而不是下载慢。之前直接滚动会导致这些卡片
# 永远漏下载。重试后仍超时才滚动,靠下游 MD5 查重兜底重复。
print(f" 轮 {r+1}: 等待 {waited}s 超时,{done}/{len(tapped_cells)} 个已打勾,"
f"仍有 {len(pending)} 个未完成,重试点击未完成的卡片...")
for (gx, cy) in pending:
adb("shell", "input", "tap", str(gx), str(cy))
time.sleep(0.5)
# 重试后再等一轮
retry_waited = 0
while retry_waited < max_wait_per_round:
# 超时未打勾:先不重试点击(队列满时重试无效),再等一轮让正在下载的完成
print(f" 轮 {r+1}: 等待 {waited}s 后 {done}/{len(tapped_cells)} 个已打勾,"
f"仍有 {len(pending)} 个未完成,继续等待一轮...")
wait2_waited = 0
while wait2_waited < max_wait_per_round:
time.sleep(poll_interval)
retry_waited += poll_interval
wait2_waited += poll_interval
ensure_not_anr()
retry_shot = screenshot("/tmp/_retrywait.png")
retry_chk = get_checked_cells_dynamic(retry_shot, row_centers)
still_pending = [c for c in pending if not retry_chk.get(c)]
w2_shot = screenshot("/tmp/_wait2.png")
w2_chk = get_checked_cells_dynamic(w2_shot, row_centers)
still_pending = [c for c in pending if not w2_chk.get(c)]
if not still_pending:
break
if still_pending:
print(f" 轮 {r+1}: 重试后仍有 {len(still_pending)} 个未完成,照常滚动(靠下游去重兜底)")
# 两轮等待后仍未打勾,可能是点击没生效(落在间隙上)或队列满被拒绝
# 再重试点击一次,然后等最后一轮
print(f" 轮 {r+1}: 再等 {wait2_waited}s 后仍有 {len(still_pending)} 个未完成,重试点击...")
for (gx, cy) in still_pending:
adb("shell", "input", "tap", str(gx), str(cy))
time.sleep(0.5)
retry_waited = 0
while retry_waited < max_wait_per_round:
time.sleep(poll_interval)
retry_waited += poll_interval
ensure_not_anr()
retry_shot = screenshot("/tmp/_retrywait.png")
retry_chk = get_checked_cells_dynamic(retry_shot, row_centers)
still_pending = [c for c in still_pending if not retry_chk.get(c)]
if not still_pending:
break
if still_pending:
print(f" 轮 {r+1}: 三轮等待后仍有 {len(still_pending)} 个未完成,照常滚动(靠下游去重兜底)")
else:
print(f" 轮 {r+1}: 重试后全部打勾完成")
print(f" 轮 {r+1}: 全部打勾完成")
else:
print(f" 轮 {r+1}: {len(tapped_cells)} 个全部打勾完成(等待 {waited}s),累计新下载 {total} 个,开始滚动")
else: