Repository navigation
feat(weibo,ui): dual-save original and watermark-free companion images - #107
Merged
Merged
Conversation
Keep Weibo primary images strictly at official full-resolution originals (/large/ or /mw2000/) and save the /oslarge/ watermark-free maximum tier as an optional companion file (images/NN_nowm.<ext>, role image_nowm) with SHA-256 deduplication, silent skip on unavailable /oslarge/, old cached item backfill, library lifecycle support, anti-duplication in media library/feed, and an Original/Watermark-free toggle pill in the image viewer. Record DEC-078 and minimally adapt ACT-023 dual-save tests. Closes #103 Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
Owner
Author
|
Agent:已完成对 PR #107( 结论:先修复(存在 1 项 P2 阻塞问题,其余架构、协议安全、生命周期与 阻塞问题
已确认通过的审查范围
非阻塞建议
修复上述 P2 阻塞项并通过本地门禁与远端 CI 5/5 后,请通知复审(仅复核阻塞项即可)。 |
…e stem When resolving conflict deletions/reorders where a surviving page shifts to an earlier index, derive the fallback companion stem from reusableLP.Image instead of the new page index so a deleted page's NN_nowm file is never misbound to a different surviving image. Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
Owner
Author
|
Agent:已完成对 PR #107 阻塞修复提交 结论:可合并( 阻塞项与增量合入复核结果
未覆盖项(
|
Merged
7 of 8 tasks
chialecode
added a commit
that referenced
this pull request
Nov 26, 2026
…ash-merged main (#107) Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
chialecode
added a commit
that referenced
this pull request
Nov 26, 2026
…nload (based on #107) (#108) Closes #104 > 堆叠分支说明:本 PR 基于已过审的 PR #107 分支 `feat/103-weibo-dual-original-nowm`(含微博双份保存 `DEC-078`)。 ## 做了什么 实现 Issue #104 全部目标并回写 **`DEC-079`**(`docs/decisions.md`、`docs/requirements.md`、`docs/design/data-and-cache.md`、`docs/design/subscriptions.md`、`docs/ui.md`): 1. **微博缓存标准版本与零请求离线统计** - 在 `internal/library/schema.go` 新增 `WeiboCacheStandardVersion = 3`(保持 `CurrentCacheStandardVersion = 2` 不变,避免触发哔哩哔哩门限 B 无谓的 PlayURL 重探),并新增纯离线判定函数(`WeiboNeedsNoWMBackfill`、`WeiboHasAllFastCDNPicIDs`、`WeiboIsForwardItem`)与 `ListItemsMetaOnlyBySite`(绕开 200 条上限且零磁盘系统调用)。 - 服务层暴露 `BackfillSummary() (BackfillSummaryDTO, error)`(0 网络请求),离线统计 `WeiboMissingNoWM`、`WeiboLegacyLinks`、`WeiboFastCDNCandidates`、`WeiboSubscribedCount`、`WeiboFallbackDetailCount`、`TotalItems`(排除 `archivedOf` 归档快照与纯 GIF)。 2. **「全部缓存」自动联动(`internal/service/cache_conflicts.go`)** - `inspectWeiboCachedPost` 同时覆盖手动「⋯ → 全部缓存」与 7 天定期 `fullCache`: - 开启 `weiboRemoveWatermark` 且本地静态主图缺 `images/NN_nowm.*` 且 `CacheStandardVersion < 3` 时,直接复用列表页 `post` 返回 `inspectEnqueue`(0 额外 `statuses/show` 请求,保留本地原图只补伴侣图并写入 v3); - 仅含 DEC-073 前旧格式内联 URL 且等价正文未变时,纯离线经 `SaveItemMetadataOnly` 清洗并写入规范 `Text` + `Links[]`(不动媒体文件)。 3. **一键持久化历史缓存补全队列 + 纯 CDN 2~5 秒加速节奏** - 复用 `cache-queue.json`(保持 `version: 3`,所有新增字段为可选 `omitempty` 且严格脱敏),新增 `weibo_backfill` 队列并支持重启续跑、暂停/继续/取消/移除与风控/限流退避。 - 三级零浪费执行: - **A 级(纯离线旧格式链接升级)**:0 网络请求、0 延迟批处理; - **B 级(纯 CDN 2~5 秒加速补齐)**:对已落盘 `pic_id` 的条目直连无 Cookie `sinaimg.cn/oslarge/<pic_id>.<ext>` 仅补缺失 `NN_nowm` 并做占位图/魔数/SHA-256 去重与 v3 标记;队列间隔 **2~5 秒**,**0 微博 JSON API 请求、不占微博 100 次/小时额度、不触发 10~25 分钟长歇**; - **C 级(缺 `pic_id` 历史条目)**:优先按已订阅博主 UID 批量翻 `mymblog` 匹配并立刻转 2~5 秒纯 CDN 补齐,列表未覆盖项(转发/非订阅/可见范围外)再兜底逐条调 `statuses/show`,严格遵守微博原 API 节流、100 次/小时额度与风控退避。 4. **单条安全补全 + 四站点联网已缓存详情 `⋯ → 强制重新下载`** - 微博/X 详情主按钮「重新缓存」维持非破坏性按新标准补全。 - 在微博帖子/视频、X 帖子、抖音作品、B 站视频的联网已缓存详情页 `⋯` 菜单中增加 **「强制重新下载」**(排除离线 `/library/item` 与 `archivedOf` 归档快照),弹出二次确认对话框(`"将从源站重新完整下载并覆盖本机已有文件;若源站已删除或失效,仍会保留本机原文件不覆盖。"`)。 - 后端实现 `download.WithForceOverwrite(ctx)` / `ForceRecacheItem`(`auto`/`queue`/自动请求路径严格禁用),跳过本地媒体复用在 `.trace-stage-*` 从源站完整重拉,但**仍严格执行 `ErrRemoteDegradedRefused` 硬拦截保护**(源站 404/已删/占位图/试看/受限/降级时中止并保留原文件),校验全部通过后经 `.trace-prev-*` 原子替换(Windows 文件锁失败自动回滚)。 5. **UI 入口** - **「设置 › 存储」**:紧凑一行「历史缓存标准」展示离线统计,0 条时显示「历史缓存已全部符合最新标准」,>0 时提供「补全历史缓存」按钮,运行中切换为「查看补全队列」跳转任务页。 - **「任务 › 缓存队列」**:有待补全项且未在补全时顶部展示紧凑操作条「发现 N 条历史微博可补全」+「一键补全」;运行中展示「历史缓存补全 · 微博」队列卡片与实时进度。 ## 验证 - [x] `go test -v ./internal/library -run 'TestWeiboCacheStandardVersionAndOfflineHelpers|TestListItemsMetaOnlyBySiteNo200Cap'` — PASS - [x] `go test -v ./internal/download -run 'TestEffectiveForceOverwriteManualOnlyContract|TestBackfillWeiboNoWMCompanionsDirectCDNAndRateLimitStop|TestForceOverwriteAcrossSitesAndDegradedRefusal|TestForceOverwriteBilibiliVideoAndDegradedRefusal'` — PASS - [x] `go test -v ./internal/service -run 'TestBackfillSummaryZeroNetworkAndCounts|TestFullCacheLinkageWeiboNoWMAndLegacyLinks|TestWeiboBackfillQueueThreeTierFastCDNQuotaAndRestartRecovery|TestServiceForceRecacheItemOverwriteAndGuards'` — PASS - [x] `go test -v ./internal/ui -run 'TestSettingsStorageAndTasksQueueBackfillUI|TestDetailMenusForceRecacheConfirmModalAllFourSites'` — PASS - [x] `go run ./tools/uishots` — PASS(312 张合成截图全部通过) - [x] `go run ./tools/check` — PASS(`gofmt`、`go vet`、`go test ./...`、`dependency direction`、`trace-server linux build`、`tools/checkdocs`、`git diff --check HEAD` 全部通过) - 真实站点网络请求:`not-run`(全部使用合成样本与本地回环桩,0 真实外网请求)。 ## 风险 - 无任何数据文件结构版本升级:`item.json` 保持 v1、`cache-queue.json` 保持 v3、`settings.json` 保持 v1、`library.db` 保持 v2,全部新增字段均为可选 `omitempty` 向后兼容。 - 未触碰 `internal/credential`、`tools/package`、`tools/internal/build`、`tools/actcheck`、`internal/sitecheck`、`.github/` 等高风险路径。 - `ForceOverwrite` 仅限显式手动触发,且受 `ErrRemoteDegradedRefused` 与 `.trace-prev-*` 原子交换回滚保护。 - [x] 低风险 - [ ] 高风险(已加 `risk:high`,等用户合并) 每个提交都带 `Signed-off-by`(`git commit -s`)。 --------- Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #103
做了什么
基于 ACT-023 V-07 与单帖对照实测确认微博
/oslarge/为 690px 宽无水印最大档而非无损原分辨率,落实 DEC-078,撤回 PR #95 替换主图的做法,改为官方原图 + 无水印伴侣文件双份保存并在看图层支持一键切换(关联FR-WB-006、DEC-078):internal/site/types.go、internal/site/weibo/、internal/download/douyin_plan.go):weibo.ImageAsset.URL恒定保持官方最高清原图largest(/large/或/mw2000/),绝不再改写为/oslarge/。weibo.ImageAsset、site.MediaImageAsset、download.PlannedNotePage新增运行期字段WatermarkFreeURL(json:"-",绝不落盘;buildPostSnapshot亦清零),开启设置且非 GIF 时通过RewriteWatermarkFreeImageURL生成/oslarge/伴侣下载地址。internal/download/):images/NN.<ext>(role: "image")后,在WatermarkFreeURL != ""时用无 Cookie +Referer: https://weibo.com/下载器另存无水印伴侣图images/NN_nowm.<ext>(role: "image_nowm",notePages[].noWatermark指向它),跳过 GIF。/oslarge/返回 404/403/HTML/损坏/占位图/网络错时静默跳过,绝不拖垮主图也不记缺失黄点(站点停止/取消/存储错照常上抛)。hasProtectedLocal && !isConflict)时复用已有有效主图(含无mediaId的旧清单),顺带补齐缺失的images/NN_nowm.<ext>并原子写入item.json;关闭开关重缓存时单调保留已有有效伴侣文件;冲突删图重排时严格按reusableLP.Image原页前缀匹配旧伴侣文件,绝不跨页错挂。internal/library/、internal/ui/):NotePageRecord新增可选向后兼容字段NoWatermark(json:"noWatermark,omitempty");visitManifestFiles、MergeItemMetadata、KeepListedFiles、ArchiveItemSnapshot、RefreshIndex、PlanDelete/Delete与MediaPath完整支持image_nowm伴侣文件。role == "image"主图,image_nowm绝不重复出现成第二张图片卡片。internal/ui/、tools/uishots/scenes.go):settings.json保持 v1 既有键weiboRemoveWatermark(默认true),「设置 › 缓存与下载」文案更新为 「微博同时保存无水印版」,说明“主图保存官方原图,同时额外保存无水印最大版(oslarge),GIF 跳过。”,切换仍立即清理内存weiboPostCache。ImageViewerState关联已缓存条目的无水印伴侣图(支持NotePageRecord.NoWatermark及images/NN_nowm.*匹配并校验文件存在),默认显示原图;当当前幻灯片存在伴侣图时,顶部悬浮栏展示简洁的 「原图 / 无水印」 胶囊切换控件,点击即时切图;切换至无伴侣图的幻灯片时自动隐藏按钮并显示原图不报错。tools/actcheck与文档回写:tools/actcheck/act022.go与act022_test.go仅同步defaultWatermarkRewriteApplied(校验主图保持/large/且WatermarkFreeURL为/oslarge/)、estimateCDNReqs(计入双份保存伴侣请求)及TestAct023DefaultWatermarkRewriteAndFallback(验证双份落盘与伴侣 404 不拖垮主图);未改动任何额度上限、账本逻辑或停止条件,未删减或弱化任何断言。docs/decisions.md新增 DEC-078,同步更新docs/requirements.md、docs/design/data-and-cache.md、docs/research/weibo.md、docs/ui.md、docs/delivery/roadmap.md。验证
go test -v ./internal/site/weibo -run 'TestRewriteWatermark|TestBuildImageAsset|TestFetchImageLimitedOSLarge|TestPostOver9ImagesOrderGIFLivePhotoMixedAndWatermarkHook'— PASSgo test -v ./internal/download -run 'TestWeiboDualSave|TestWeiboConflictDeleteReorderDoesNotMisbindCompanion'— PASS(8 项双份/去重/404/403/HTML/坏图/截断/占位图子测试 + GIF 跳过/旧条目复用主图补齐伴侣/关开关单调保留 + 冲突删图重排不跨页错挂/精准复用自身伴侣回归测试)go test -v ./internal/library -run 'TestWeiboNoWatermarkCompanion'— PASS(登记/MediaPath/列表不重复/合并与裁剪/归档/刷新检测/删除清理)go test -v ./internal/service -run 'TestWeiboRemoveWatermark|TestWeiboFavoritesAccountPageMediaRetweetCacheStateAndPlanReuseGuard'— PASSgo test -v ./internal/ui -run 'TestWeiboWatermark|TestDownloadSettingsWeibo|TestLibraryGridDoesNotDuplicate|TestWeiboImageViewerToggle'— PASSgo test -v ./tools/actcheck -run 'TestAct023DefaultWatermark'— PASSgo run ./tools/uishots -out artifacts/uishots— 312 张截图全部通过(已目视复核settings-download-{1280,720}x860.png)go run ./tools/check— 全绿(gofmt、go vet、go test ./...、依赖方向、trace-serverLinux 构建、tools/checkdocs、git diff --check HEAD全绿;36 个改动文件纯 LFCR=0)not-run(本次改动与单测仅使用合成夹具,未发起任何真实站点请求;go test -race:not-run,本机无 cgo 工具链)。风险
risk:high,等用户合并)高风险原因:按
docs/dev-rules/workflow.md#high-risk,本 PR 为使go test ./.../ CI 与 DEC-078 同步,对tools/actcheck/act022.go与tools/actcheck/act022_test.go做了最小精确适配(仅同步双份保存断言与 CDN 请求估算,绝未修改额度上限、账本与停止条件)。其余数据结构均严格向后兼容:settings.json(v1)、item.json(v1)、library.db(v2)与全局CurrentCacheStandardVersion(v2)均未升版本,未触碰internal/credential、tools/package或.github/。每个提交都带
Signed-off-by(git commit -s)。