图库: 书库点图改按文件名定位(修 P1 截断错位)+ 册间衔接根锁定(M18 评审 r1)

P1-1(会静默开错图):取消「书库从列表推导图片下标」。
- 新增 mr_reader_open_dir_at_name(dir, name):阅读器打开目录册后,在**自己刚枚举出的
  全量目录册**(mr_dir_book,与翻页同一份枚举)里按 basename 定位起始页(先精确,
  再大小写不敏感兜底;找不到退回续读/首页)。书库点击只传文件名。
- 删除 mr_library_image_index(不再有跨枚举的隐式契约)。
- 截断提示文案改为「仅显示前 2000 项(图片可在阅读器中翻到)」。
- 修复前(cb02722 探针,2100 张 4 位名夹具):rows=2000/truncated=1/
  library_images=2000/reader_pages=2100/**mismatched=590**(首行 p1412 → 打开 p1411);
  评审夹具为 1995/2000。修复后:2000 个可见图片行按名定位 **0 mismatch**,
  2100 页全量可翻;26 次真实 UI 点开(首尾各 3 + 20 个确定性伪随机)逐张命中。

连带处理(评审 r1):
1. 删掉 reader_page_enter 的 c->view 死写(reopen 判定用 activity active/depth);
   顺手删掉 library_page_create 里同款死写。
2. 阅读器册间衔接根锁定:新增 mr_path_within_root + mr_book_adjacent_rooted,
   book_switch 用浏览根(默认 MR_ROOT_DIR,测试可注入)钳制相邻册;
   根外的兄弟册按「没有相邻册」处理。test_cont_adjacent A7 验证「明文 _ex 会越根、
   rooted 拒绝、根内翻册不受影响」;test_mode_switch_host H6 验证条漫末页不越根。
3. test_reader_perf 不再依赖顶栏 tap 命中时序:模式切换改走测试钩子
   mr_reader_test_toggle_mode()(与顶栏动作同一个 mode_set),负载下稳定。
4. page_cache 注释去掉「缩略图缓存/缩略图线程」过时描述(只改文字)。

回归:run_tests.sh(library 81 / nav 74 / lazy 57 / perf 25 / … / open_book 含 2100 用例)
与 run_webtoon_tests.sh(含 A7/H6)全 PASS;交叉构建零警告。
This commit is contained in:
AskaEth committed 2026-11-05 20:26:40 +08:00
1 parent 64336f95d9
commit 4befbfe14c
17 files changed
+523 -112

No files matched your search

+32 -9
View File
@@ -257,13 +257,16 @@ int mr_library_scan(mr_library *lib, const char *dir, int max_depth)
int mr_library_row_at(const mr_library *lib, int idx, mr_library_row *out)
{
static char trunc_sub[48];
static char trunc_sub[96];
static int trunc_ready;
if (!lib || !out) return 0;
if (idx == lib->count && lib->truncated) {
if (!trunc_ready) {
snprintf(trunc_sub, sizeof trunc_sub, "仅显示前 %d 项", MR_LIB_SCAN_MAX);
/* 截断只是列表显示上限:图片仍能从任一可见图片进入阅读器后翻到,
* 文案不要让人误以为「没有更多图片」。 */
snprintf(trunc_sub, sizeof trunc_sub,
"仅显示前 %d 项(图片可在阅读器中翻到)", MR_LIB_SCAN_MAX);
trunc_ready = 1;
}
memset(out, 0, sizeof *out);
@@ -284,14 +287,15 @@ int mr_library_row_at(const mr_library *lib, int idx, mr_library_row *out)
return 1;
}
int mr_library_image_index(const mr_library *lib, int idx)
int mr_path_within_root(const char *path, const char *root)
{
if (!lib || idx < 0 || idx >= lib->count) return -1;
if (lib->items[idx].kind != MR_LIB_KIND_IMAGE) return -1;
int n = 0;
for (int i = 0; i < idx; i++)
if (lib->items[i].kind == MR_LIB_KIND_IMAGE) n++;
return n;
if (!path || !path[0] || !root || !root[0]) return 0;
size_t rl = strlen(root);
while (rl > 1 && root[rl - 1] == '/') rl--;
if (rl == 1 && root[0] == '/') return path[0] == '/';
if (strncmp(path, root, rl) != 0) return 0;
char c = path[rl];
return c == '\0' || c == '/';
}
int mr_path_parent(const char *path, char *out, int outsz)
@@ -433,6 +437,25 @@ int mr_book_adjacent_ex(const char *dir, int delta, char *out, int outsz,
return rc;
}
int mr_book_adjacent_rooted(const char *dir, int delta, const char *root,
mr_lib_archive_fn archive_pages, void *ud,
char *out, int outsz)
{
if (!out || outsz <= 0) return -1;
out[0] = '\0';
if (!dir || !dir[0] || !root || !root[0]) return -1;
/* 只允许在浏览根内翻册:当前册或相邻册越根一律当「没有相邻册」。 */
if (!mr_path_within_root(dir, root)) return 0;
int r = mr_book_adjacent_ex(dir, delta, out, outsz, archive_pages, ud);
if (r != 1) return r;
if (!mr_path_within_root(out, root)) {
out[0] = '\0';
return 0;
}
return 1;
}
int mr_book_adjacent(const char *dir, int delta, char *out, int outsz)
{
return mr_book_adjacent_ex(dir, delta, out, outsz, NULL, NULL);