跳到主要内容

checkRestoreCompatibility()

function checkRestoreCompatibility(
executor,
codec,
target
): Promise<RestoreCompatibility>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/restore-precheck.ts:297

判断「把工作树恢复到目标 commit」在当前客户端是否可行。

Parameters​

ParameterTypeDescription
executorTransactionExecutor当前事务执行器
codecWorkingTreePatchCodecContext元数据解析上下文,见 WorkingTreePatchCodecContext
targetWorkingTreeRestoreTarget恢复目标,见 WorkingTreeRestoreTarget

Returns​

Promise<RestoreCompatibility>

见 RestoreCompatibility

Throws​

RxDBError 目标不在当前分支 HEAD 的可达父链上

Remarks​

本函数一个字节都不写。 「检查」这个词本身就是只读的承诺;顺手写一行状态的话,它就没法 被 restore 之外的入口(比如 UI 的「这个版本能不能恢复」预览)安全复用,而那个预览正是 把这一段拆成独立函数的理由。

目标不可达时抛而不是返回失败出口:那是调用方的前置条件。restore-command.ts 先用 selectRestoreReplayPath 判可达性并把它转成自己的失败 reason,走到这里时 「可达」已经成立;这条 throw 只会在有人跳过那一步时触发,而那是代码缺陷,不是用户输入。