Files
goodbuddy/src/main/assistant-storage-worker.ts
T
mesalogo 38d0923d79 fix: stop repeated history migration after restart
Desktop 0.13.8 still treated SQLite freelist pages left by normal chat and note writes as evidence of pending migration when a file-backed note existed. Migration detection now checks only the schema version and legacy note payloads, while the startup worker reuses its confirmed pending decision during retries so actual migrations can still finish compaction.

Release note: 修复已有笔记用户正常聊天后重启仍重复显示历史迁移的问题;已完成迁移的数据继续按新格式保存,普通写入产生的空闲页不再触发迁移。
2026-09-21 12:31:14 +08:00

26 lines
1010 B
TypeScript

import { parentPort, workerData } from 'node:worker_threads'
import { upgradeAssistantStorage } from './assistant/assistant-storage-upgrade'
const input = workerData as {
databasePath: string
cancellation: SharedArrayBuffer
}
const cancellation = new Int32Array(input.cancellation)
try {
// Startup checks for legacy data before spawning this worker, including retries.
upgradeAssistantStorage(
input.databasePath,
(progress) => parentPort?.postMessage({ progress }),
() => Atomics.load(cancellation, 0) !== 0,
{ pendingUpgradeConfirmed: true }
)
parentPort?.postMessage({ done: true })
} catch (error) {
parentPort?.postMessage({
error: error instanceof Error && /full|space/iu.test(error.message)
? '磁盘空间不足,无法完成空间回收。请释放一些空间后重试。'
: '历史执行记录优化未完成。请重试;若仍失败,请备份数据并联系支持。',
cancelled: error instanceof Error && error.name === 'AbortError'
})
}