- 渲染管线迁移至 MetonaEditor 内置解析器,移除 unified/rehype 全家桶(9 个依赖) - 修复相对路径图片修复的目录前缀碰撞与路径解析 bug - ConfirmDialog/useConfirm/LoadingSpinner/useDocStats 移除,改用 MeToast.confirm/loading/promise - 新增状态栏(字数/行数/阅读时间/光标位置)、Zen 模式、数据备份导出导入 - Sqlark: 版本化迁移(addMigration/migrateTo)、subscribe 表变更、备份 exportAll/importTable - 数据库损坏自愈:异常退出残留残缺 SSTable 导致打开失败时自动重建 - 大纲导航改用 scrollToLine 官方 API - 修复 rollup 平台包互删(postinstall 自动补齐)+ 集成测试(fake-indexeddb)
35 lines
1.5 KiB
JavaScript
35 lines
1.5 KiB
JavaScript
import 'fake-indexeddb/auto'
|
|
import { create } from '/mnt/d/CodeWorkspace/MarkLite/node_modules/@metona-team/metona-sqlark/dist/metona-sqlark.esm.js'
|
|
|
|
const DB = 'aria-corrupt-test'
|
|
|
|
// 1. 正常建库写数据
|
|
const db1 = await create({ name: 'corrupt-test', mode: 'aria', diskEngine: 'indexeddb', version: 0 })
|
|
await db1.defineTable('recentFiles', { filePath: { type: 'string', primaryKey: true }, lastOpened: { type: 'number' } })
|
|
await db1.table('recentFiles').insert({ filePath: '/a.md', lastOpened: 1 })
|
|
await db1.close()
|
|
|
|
// 2. 模拟异常退出留下的残缺 SSTable 页面:直接往 IDB 写一个 10 字节的 pg_ 文件
|
|
await new Promise((resolve, reject) => {
|
|
const req = indexedDB.open(DB, 1)
|
|
req.onsuccess = () => {
|
|
const idb = req.result
|
|
const tx = idb.transaction('data', 'readwrite')
|
|
tx.objectStore('data').put(new ArrayBuffer(10), 'pg_1') // 残缺页面(正常 4096 字节)
|
|
tx.oncomplete = () => { idb.close(); resolve() }
|
|
tx.onerror = () => reject(tx.error)
|
|
}
|
|
req.onerror = () => reject(req.error)
|
|
})
|
|
|
|
// 3. 重新打开 → 应该抛 offset is out of bounds
|
|
try {
|
|
const db2 = await create({ name: 'corrupt-test', mode: 'aria', diskEngine: 'indexeddb', version: 0 })
|
|
const rows = await db2.table('recentFiles').select().execute()
|
|
console.log('S2 opened OK, rows:', JSON.stringify(rows))
|
|
await db2.close()
|
|
console.log('NO ERROR — 未能复现')
|
|
} catch (e) {
|
|
console.log('REPRODUCED:', e.constructor.name, '|', e.message)
|
|
}
|