Skip to content

🔥 移除图库图片零点预热机制 - #53

Open
MimoKit wants to merge 1 commit into
mainfrom
remove-gallery-prefetch
Open

MimoKit wants to merge 1 commit into
mainfrom
remove-gallery-prefetch

Conversation

@MimoKit

@MimoKit MimoKit commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

改动

移除图库图片的零点前预热(提前下载)机制,含其全部配置项:

  • 删除 TodayWaifu/prefetch.py 整模块:23:20 预热窗口、限速下载、每日一次状态文件、调度循环
  • 删除 TodayWaifu/constants.py 中全部 PREFETCH_* 常量
  • 删除配置项 DailyWifePrefetchEnabled(零点前预热图库图片)与 DailyWifePrefetchImagesPerRole(每个角色预热图片数),含 tests/compatibility_manifest.json 对应条目
  • TodayWaifu/shared.py:删除预热任务的启动/关停钩子与任务句柄,钩子改名为 _start_gallery_services_on_startup / _stop_gallery_services_on_shutdown(只保留图片投递 worker 启停与缓存索引恢复)
  • 删除 tests/test_prefetch.py 与 tests/test_image_source_switch.py 中的预热用例
  • 清理 file_cache.py、gallery.py、image_shrink.py、roles.py、senders.py 中描述预热的注释文案

保留

「抽签优先已缓存图片」(prefer_cached_urls)与启动时从磁盘恢复缓存索引保留:这两者不下载任何图片,只让已落盘的图片优先被抽中。restore_cached_url_index 原在 prefetch.py 中,本次挪入 shared.py。

验证

  • 全包 compileall 通过,代码与测试中已无 prefetch / PREFETCH / 预热残留引用
  • 测试套件共 432 个用例:除 3 个本地缺 qgbot / sqlmodel 依赖的既有环境错误外全部通过(已用改动前基线对照,错误一致,非本次引入)

Summary by CodeRabbit

  • Behavior Changes
    • Scheduled gallery-image prefetching has been removed. Images already in the cache are preferred when selecting images; if none are cached, selection continues to use the available images.
  • Configuration
    • The settings for enabling gallery-image prefetching and limiting downloads per role have been removed.

删除 `TodayWaifu/prefetch.py` 整模块(23:20 预下载循环、状态文件、限速下载)、
`constants.py` 的全部 `PREFETCH_*` 常量、`shared.py` 的预热任务启停钩子,
以及配置项 `DailyWifePrefetchEnabled`、`DailyWifePrefetchImagesPerRole`
(含兼容清单条目)与对应测试。

保留「抽签优先已缓存图片」与启动时恢复缓存索引:这两者不产生任何下载,
仅让已落盘的图片优先被抽中;`restore_cached_url_index` 由 `prefetch.py`
挪入 `shared.py`。
@github-actions github-actions Bot added the tests 测试相关变更 label Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Gallery Cache Behavior

Layer / File(s) Summary
Remove scheduled prefetch flow
TodayWaifu/constants.py, TodayWaifu/prefetch.py, TodayWaifu/shared.py, config_default.py, tests/compatibility_manifest.json, tests/test_image_source_switch.py, tests/test_prefetch.py
The scheduled prefetch module, its configuration entries, and its startup task state were removed. The related prefetch tests were removed.
Restore cached URLs and prefer cached images
TodayWaifu/shared.py, TodayWaifu/roles.py, TodayWaifu/file_cache.py, TodayWaifu/gallery.py, TodayWaifu/image_shrink.py, TodayWaifu/senders.py, tests/test_cached_url_preference.py
Startup restores the cached-URL index. Role selection prefers cached URLs when available. Related comments, docstrings, and test descriptions were updated.

Suggested reviewers: linsheng0s, xbaiyz12

Change: Other

Merge Risk: Minimal · up to 52a38

This PR removes the scheduled gallery image prefetch and its settings. Startup still restores the cached-image index, and role selection still prefers already-cached images. No merge-blocking risk was found. Operators who still set the removed prefetch config keys should be aware those settings no longer do anything.

Security architecture risk: Minimal · up to 52a38

The change removes background image downloads while preserving existing cache restoration, image selection, and delivery-worker lifecycle behavior. The inspected changes establish no introduced or worsened security, failure-containment, or rollback risk.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected exposure change removes the scheduled gallery-download trigger. Relocating restoration does not increase its local-file authority or introduce a new externally callable download path.

Trust Boundaries and Controls

  • observed — The existing cache boundary uses SHA-256-derived URL filenames, and preference only narrows the existing role-image candidate set. Restoration trusts matching local filenames without inspecting image contents; this behavior predates the PR rather than representing a newly introduced validation bypass.
Finishing Touches

Generate unit tests (beta)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9bb7645-4cd8-424a-982b-12e9b175d13f
Commits

Reviewing files that changed from the base of the PR and between de92696 and 52a38dd.

Files selected for processing: 13

  • TodayWaifu/constants.py
  • TodayWaifu/file_cache.py
  • TodayWaifu/gallery.py
  • TodayWaifu/image_shrink.py
  • TodayWaifu/prefetch.py
  • TodayWaifu/roles.py
  • TodayWaifu/senders.py
  • TodayWaifu/shared.py
  • config_default.py
  • tests/compatibility_manifest.json
  • tests/test_cached_url_preference.py
  • tests/test_image_source_switch.py
  • tests/test_prefetch.py
Files with no reviewable changes: 6

  • TodayWaifu/constants.py
  • TodayWaifu/prefetch.py
  • config_default.py
  • tests/compatibility_manifest.json
  • tests/test_image_source_switch.py
  • tests/test_prefetch.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Note

Unit test generation is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Coding Agent task started for unit test generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests 测试相关变更

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant