dsh-config-manager 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.d.ts +21 -2
- package/lib/client.js +558 -550
- package/lib/core/messages-core.d.ts +1 -0
- package/lib/core/messages-core.js +2 -0
- package/lib/core/migration-history.d.ts +18 -2
- package/lib/core/migration-history.js +19 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/lib/sync/autosync-scheduler.js +6 -2
- package/lib/sync/baseline-heal.d.ts +35 -0
- package/lib/sync/baseline-heal.js +39 -0
- package/lib/sync/push-precheck.d.ts +35 -0
- package/lib/sync/push-precheck.js +58 -0
- package/lib/sync/sync-engine.d.ts +9 -12
- package/lib/sync/sync-engine.js +24 -43
- package/lib/ui/history-model.js +3 -2
- package/lib/ui/overview-view.d.ts +3 -3
- package/lib/ui/overview-view.js +9 -1
- package/package.json +1 -1
- package/src/client/history/history-locales.ts +2 -0
- package/src/client/home/HomePanel.tsx +9 -3
- package/src/client/locales.ts +2 -0
- package/src/client/sync/history-model.ts +3 -0
- package/src/client/sync/sync-locales.ts +2 -0
- package/src/core/messages-core.ts +2 -0
- package/src/core/migration-history.test.ts +19 -0
- package/src/core/migration-history.ts +28 -5
- package/src/index.ts +3 -3
- package/src/sync/autosync-scheduler.test.ts +23 -0
- package/src/sync/autosync-scheduler.ts +6 -2
- package/src/sync/baseline-heal.ts +74 -0
- package/src/sync/push-precheck.ts +75 -0
- package/src/sync/sync-engine.test.ts +88 -0
- package/src/sync/sync-engine.ts +33 -43
- package/src/ui/history-model.test.ts +2 -1
- package/src/ui/history-model.ts +3 -2
- package/src/ui/overview-view.test.ts +12 -0
- package/src/ui/overview-view.ts +12 -4
|
@@ -64,6 +64,7 @@ export declare const zh: {
|
|
|
64
64
|
'core.migrationHistory.resultSuccess': string;
|
|
65
65
|
'core.migrationHistory.resultFailed': string;
|
|
66
66
|
'core.migrationHistory.resultSkipped': string;
|
|
67
|
+
'core.migrationHistory.resultPending': string;
|
|
67
68
|
'core.localPluginPack.dirCreateFailed': string;
|
|
68
69
|
'core.localPluginPack.tarballTooLarge': string;
|
|
69
70
|
'core.localPluginPack.packFailed': string;
|
|
@@ -76,6 +76,7 @@ export const zh = {
|
|
|
76
76
|
'core.migrationHistory.resultSuccess': '成功',
|
|
77
77
|
'core.migrationHistory.resultFailed': '失败',
|
|
78
78
|
'core.migrationHistory.resultSkipped': '跳过',
|
|
79
|
+
'core.migrationHistory.resultPending': '待裁决',
|
|
79
80
|
// ---------- local-plugin-pack ----------
|
|
80
81
|
'core.localPluginPack.dirCreateFailed': '本地插件打包目录创建失败,已跳过全部本地插件: {reason}',
|
|
81
82
|
'core.localPluginPack.tarballTooLarge': '本地插件 {name} 的 tarball 超过上限({size} > {max} 字节),已跳过打包',
|
|
@@ -372,6 +373,7 @@ export const en = {
|
|
|
372
373
|
'core.migrationHistory.resultSuccess': 'success',
|
|
373
374
|
'core.migrationHistory.resultFailed': 'failed',
|
|
374
375
|
'core.migrationHistory.resultSkipped': 'skipped',
|
|
376
|
+
'core.migrationHistory.resultPending': 'needs decision',
|
|
375
377
|
// ---------- local-plugin-pack ----------
|
|
376
378
|
'core.localPluginPack.dirCreateFailed': 'Failed to create the local plugin packing directory; skipped all local plugins: {reason}',
|
|
377
379
|
'core.localPluginPack.tarballTooLarge': 'The tarball of local plugin {name} exceeds the limit ({size} > {max} bytes); skipped packing',
|
|
@@ -19,8 +19,24 @@ export declare function resolveHistoryRetention(configured: unknown): number;
|
|
|
19
19
|
declare const MIGRATION_KINDS: readonly ['import', 'restore', 'rollback', 'profile-create', 'profile-select', 'profile-switch', 'profile-delete', 'profile-rename', 'profile-save', 'profile-import', 'sync-apply', 'autosync', 'recovery', 'backup', 'backup-manual', 'snapshot-delete', 'snapshot-prune'];
|
|
20
20
|
/** §5 覆盖的操作 kind(COMPLETE 不变量;常量枚举,天然非敏感)。 */
|
|
21
21
|
export type MigrationKind = (typeof MIGRATION_KINDS)[number];
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 操作结果。
|
|
24
|
+
*
|
|
25
|
+
* 'pending'(0.4.1):操作**跑完了但仍有待裁决项**(自动同步上传成功、下行冲突未裁决;
|
|
26
|
+
* 合并已应用一部分)。它不是 failed —— 网络/凭据/repo 都是好的;也不是 skipped ——
|
|
27
|
+
* 那一轮确实做了事。旧实现把 partial 直接折成 'failed',用户看到「自动同步 失败」而
|
|
28
|
+
* 实际只需要在同步页确认一次冲突。读侧(parseEntry / query 解析)必须接受该值,
|
|
29
|
+
* 否则含 pending 的历史条目会被整条丢弃。
|
|
30
|
+
*/
|
|
31
|
+
export type MigrationResult = 'success' | 'failed' | 'skipped' | 'pending';
|
|
32
|
+
/**
|
|
33
|
+
* 自动同步一轮的状态 → 历史 result(宿主 appendHistoryFn 的唯一映射,0.4.1)。
|
|
34
|
+
*
|
|
35
|
+
* 关键一条:`partial`(跑完了但仍有待裁决分区)**不是** failed —— 通道与凭据都正常,
|
|
36
|
+
* 只是需要用户在同步页确认一次冲突。落成 failed 会让首页红字报「同步失败」,
|
|
37
|
+
* 用户据此去查网络/凭据,方向完全错。
|
|
38
|
+
*/
|
|
39
|
+
export declare function historyResultFromAutosyncStatus(status: 'success' | 'skipped' | 'partial' | 'failed'): MigrationResult;
|
|
24
40
|
/** 触发来源(常量)。 */
|
|
25
41
|
export type MigrationSource = 'api' | 'autosync' | 'backup-scheduler' | 'recovery' | 'cli' | 'internal';
|
|
26
42
|
/** 一条不可变的迁移历史记录(磁盘形态;schemaVersion 内联)。 */
|
|
@@ -66,6 +66,20 @@ const MIGRATION_KINDS = [
|
|
|
66
66
|
'sync-apply', 'autosync', 'recovery',
|
|
67
67
|
'backup', 'backup-manual', 'snapshot-delete', 'snapshot-prune',
|
|
68
68
|
];
|
|
69
|
+
/**
|
|
70
|
+
* 自动同步一轮的状态 → 历史 result(宿主 appendHistoryFn 的唯一映射,0.4.1)。
|
|
71
|
+
*
|
|
72
|
+
* 关键一条:`partial`(跑完了但仍有待裁决分区)**不是** failed —— 通道与凭据都正常,
|
|
73
|
+
* 只是需要用户在同步页确认一次冲突。落成 failed 会让首页红字报「同步失败」,
|
|
74
|
+
* 用户据此去查网络/凭据,方向完全错。
|
|
75
|
+
*/
|
|
76
|
+
export function historyResultFromAutosyncStatus(status) {
|
|
77
|
+
if (status === 'success')
|
|
78
|
+
return 'success';
|
|
79
|
+
if (status === 'skipped')
|
|
80
|
+
return 'skipped';
|
|
81
|
+
return status === 'partial' ? 'pending' : 'failed';
|
|
82
|
+
}
|
|
69
83
|
const defaultIo = {
|
|
70
84
|
async mkdir(d, o) { await fs.mkdir(d, o); },
|
|
71
85
|
async readdirNames(d) { try {
|
|
@@ -218,7 +232,7 @@ function parseEntry(text) {
|
|
|
218
232
|
return null;
|
|
219
233
|
if (typeof p.at !== 'string' || p.at === '')
|
|
220
234
|
return null;
|
|
221
|
-
if (!['success', 'failed', 'skipped'].includes(p.result))
|
|
235
|
+
if (!['success', 'failed', 'skipped', 'pending'].includes(p.result))
|
|
222
236
|
return null;
|
|
223
237
|
if (typeof p.source !== 'string')
|
|
224
238
|
return null;
|
|
@@ -397,7 +411,9 @@ export function renderExport(entries, format, locale = 'zh') {
|
|
|
397
411
|
? T('core.migrationHistory.resultSuccess')
|
|
398
412
|
: r === 'failed'
|
|
399
413
|
? T('core.migrationHistory.resultFailed')
|
|
400
|
-
:
|
|
414
|
+
: r === 'pending'
|
|
415
|
+
? T('core.migrationHistory.resultPending')
|
|
416
|
+
: T('core.migrationHistory.resultSkipped');
|
|
401
417
|
if (format === 'json') {
|
|
402
418
|
const stats = summarizeHistory(entries);
|
|
403
419
|
return redact(JSON.stringify({ title: L.title, stats, entries }, null, 2));
|
|
@@ -424,7 +440,7 @@ export function parseHistoryQuery(raw) {
|
|
|
424
440
|
q.kinds = kinds.filter(isValidMigrationKind);
|
|
425
441
|
const results = parseList(raw['result']);
|
|
426
442
|
if (results.length > 0)
|
|
427
|
-
q.result = results.filter((r) => r === 'success' || r === 'failed' || r === 'skipped');
|
|
443
|
+
q.result = results.filter((r) => r === 'success' || r === 'failed' || r === 'skipped' || r === 'pending');
|
|
428
444
|
const sections = parseList(raw['sections']);
|
|
429
445
|
if (sections.length > 0)
|
|
430
446
|
q.sections = sections;
|
package/lib/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare const name = "config-manager";
|
|
|
77
77
|
/** Services required before the engine can mount (present in every profile). */
|
|
78
78
|
export declare const inject: string[];
|
|
79
79
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
80
|
-
export declare const PLUGIN_VERSION = "0.4.
|
|
80
|
+
export declare const PLUGIN_VERSION = "0.4.1";
|
|
81
81
|
/**
|
|
82
82
|
* Star 引导弹窗指向的 GitHub 仓库(用户引导点 Star 的目标)。
|
|
83
83
|
* 与 package.json 的 repository 字段保持一致;界面不可改(硬编码,参照
|
package/lib/index.js
CHANGED
|
@@ -106,7 +106,7 @@ import { AUTO_BACKUP_PREFIX, isValidExportFileName, resolveNonCollidingExportNam
|
|
|
106
106
|
import { DEFAULT_RETENTION_POLICY, selectPruneCandidatesByPolicy } from './sync/retention-policy.js';
|
|
107
107
|
import { selectPruneCandidates } from './core/backup.js';
|
|
108
108
|
import { appendAutosyncEntry } from './sync/sync-history.js';
|
|
109
|
-
import { MigrationStore, MIGRATION_HISTORY_DIR } from './core/migration-history.js';
|
|
109
|
+
import { MigrationStore, historyResultFromAutosyncStatus, MIGRATION_HISTORY_DIR } from './core/migration-history.js';
|
|
110
110
|
import { createHistoryPruner } from './core/history-prune.js';
|
|
111
111
|
import { validateRepoUrl, validateWebDavUrl, isWebDavConfig, isS3Config, isGistConfig, channelOf, parseSyncChannel, SYNC_CHANNELS, GIST_PROVIDER, isS3CompatProvider, validateCloudChannelInput, cloudSecretRef } from './sync/sync-config.js';
|
|
112
112
|
import { resolveSessionFormatDisposition, sessionFormatAbortResponse, } from './routes/session-format.js';
|
|
@@ -139,7 +139,7 @@ export const name = 'config-manager';
|
|
|
139
139
|
/** Services required before the engine can mount (present in every profile). */
|
|
140
140
|
export const inject = ['settings', 'credentials'];
|
|
141
141
|
/** Plugin version, kept in sync with package.json ("version"). */
|
|
142
|
-
export const PLUGIN_VERSION = '0.4.
|
|
142
|
+
export const PLUGIN_VERSION = '0.4.1';
|
|
143
143
|
/** Plugin own package name — excluded from its own exported plugins list. */
|
|
144
144
|
const PLUGIN_NAME = 'dsh-config-manager';
|
|
145
145
|
/**
|
|
@@ -2680,7 +2680,7 @@ function makeRoutes(deps) {
|
|
|
2680
2680
|
await appendAutosyncEntry(syncDir, entry).catch(() => undefined);
|
|
2681
2681
|
await history.append({
|
|
2682
2682
|
kind: 'autosync',
|
|
2683
|
-
result: entry.status
|
|
2683
|
+
result: historyResultFromAutosyncStatus(entry.status),
|
|
2684
2684
|
sections: entry.appliedSections ?? [],
|
|
2685
2685
|
source: 'autosync',
|
|
2686
2686
|
summary: engineMsg('host.autosyncSummary', {
|
|
@@ -743,11 +743,15 @@ export class AutoSyncScheduler {
|
|
|
743
743
|
: partial
|
|
744
744
|
? conflictedSections
|
|
745
745
|
: deferredSections;
|
|
746
|
+
// 0.4.1:推送前收养了「本机自己推上去的」远端快照(上次推送在写基线前被打断)→
|
|
747
|
+
// 如实记一条 skipReason,让历史与首页能说清「这次推上去之前先修好了基线」,
|
|
748
|
+
// 而不是让用户以为又发生了一次莫名冲突。冲突原因优先(真有冲突时更该被看见)。
|
|
749
|
+
const adoptedReason = pushReport.adoptedBase !== undefined ? 'baseline-adopted' : undefined;
|
|
746
750
|
const result = {
|
|
747
751
|
status: partial ? 'partial' : 'success',
|
|
748
752
|
direction: appliedSections.length ? 'both' : 'push',
|
|
749
753
|
appliedSections, pushedSnapshotId: pushReport.snapshotId, historyId,
|
|
750
|
-
...(skipReason !== undefined ? { skipReason } : {}),
|
|
754
|
+
...(skipReason !== undefined || adoptedReason !== undefined ? { skipReason: skipReason ?? adoptedReason } : {}),
|
|
751
755
|
...(reportedConflicted.length > 0 ? { conflictedSections: reportedConflicted } : {}),
|
|
752
756
|
consecutiveFailures: 0,
|
|
753
757
|
...forcedMark,
|
|
@@ -756,7 +760,7 @@ export class AutoSyncScheduler {
|
|
|
756
760
|
direction: appliedSections.length ? 'both' : 'push',
|
|
757
761
|
status: partial ? 'partial' : 'success',
|
|
758
762
|
appliedSections, pushedSnapshotId: pushReport.snapshotId,
|
|
759
|
-
...(skipReason !== undefined ? { skipReason } : {}),
|
|
763
|
+
...(skipReason !== undefined || adoptedReason !== undefined ? { skipReason: skipReason ?? adoptedReason } : {}),
|
|
760
764
|
...(reportedConflicted.length > 0 ? { conflictedSections: reportedConflicted } : {}),
|
|
761
765
|
createdAt: nowIso, failureCountAtRun: 0,
|
|
762
766
|
...forcedMark,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MsgFunc } from '../core/messages.ts';
|
|
2
|
+
import type { SnapshotFs } from './fs.ts';
|
|
3
|
+
import type { SyncSnapshotMeta } from './transport.ts';
|
|
4
|
+
export interface AdoptOwnRemoteHeadOptions {
|
|
5
|
+
/** sync-state.json 所在目录。 */
|
|
6
|
+
stateDir: string;
|
|
7
|
+
fsx: SnapshotFs;
|
|
8
|
+
/** 本地快照副本目录(祖先来源);缺省 = 本机没有副本可指。 */
|
|
9
|
+
localSnapshotsDir?: string;
|
|
10
|
+
/** 远端快照列表(已按 createdAt 升序)。 */
|
|
11
|
+
metas: readonly SyncSnapshotMeta[];
|
|
12
|
+
/** 判定为「比基线新」的那份远端快照 id。 */
|
|
13
|
+
remoteId: string;
|
|
14
|
+
/** 本机当前基线(仅用于告警文案)。 */
|
|
15
|
+
base: string;
|
|
16
|
+
/** 本次通道身份(写回 sync-state.transport)。 */
|
|
17
|
+
transport: {
|
|
18
|
+
type: string;
|
|
19
|
+
ref: string;
|
|
20
|
+
};
|
|
21
|
+
hostname: string;
|
|
22
|
+
msg: MsgFunc;
|
|
23
|
+
/** 出参:收养说明追加到这里(调用方原样带给用户)。 */
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 把「本机自己推上去、但基线没跟上」的远端最新快照收养为基线。
|
|
28
|
+
*
|
|
29
|
+
* 只写 sync-state:lastSnapshotId / 每分区 hash(取**被收养快照自己**的 sectionHashes,
|
|
30
|
+
* 不是本次导出结果)/ 祖先目录名(本机真有该副本才指过去,没有就保持原祖先 —— 三方合并仍成立,
|
|
31
|
+
* 也不会被写成一个不存在的目录名)。
|
|
32
|
+
*
|
|
33
|
+
* @returns 被收养的快照 id;null = 不满足收养条件(调用方按冲突返回)
|
|
34
|
+
*/
|
|
35
|
+
export declare function adoptOwnRemoteHead(opts: AdoptOwnRemoteHeadOptions): Promise<string | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { joinFs } from './fs.js';
|
|
2
|
+
import { loadSyncState, resolveDeviceIdentity, saveSyncState } from './sync-state.js';
|
|
3
|
+
/**
|
|
4
|
+
* 把「本机自己推上去、但基线没跟上」的远端最新快照收养为基线。
|
|
5
|
+
*
|
|
6
|
+
* 只写 sync-state:lastSnapshotId / 每分区 hash(取**被收养快照自己**的 sectionHashes,
|
|
7
|
+
* 不是本次导出结果)/ 祖先目录名(本机真有该副本才指过去,没有就保持原祖先 —— 三方合并仍成立,
|
|
8
|
+
* 也不会被写成一个不存在的目录名)。
|
|
9
|
+
*
|
|
10
|
+
* @returns 被收养的快照 id;null = 不满足收养条件(调用方按冲突返回)
|
|
11
|
+
*/
|
|
12
|
+
export async function adoptOwnRemoteHead(opts) {
|
|
13
|
+
const meta = opts.metas.find((m) => m.id === opts.remoteId);
|
|
14
|
+
if (meta === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
const device = await resolveDeviceIdentity(opts.stateDir, opts.hostname, opts.fsx, opts.msg);
|
|
17
|
+
const remoteDevice = meta.manifest.deviceId;
|
|
18
|
+
if (typeof remoteDevice !== 'string' || remoteDevice === '' || remoteDevice !== device.id)
|
|
19
|
+
return null;
|
|
20
|
+
const ancestorKnown = opts.localSnapshotsDir !== undefined
|
|
21
|
+
&& await opts.fsx.isDir(joinFs(opts.localSnapshotsDir, opts.remoteId));
|
|
22
|
+
const state = await loadSyncState(opts.stateDir, opts.fsx, opts.msg);
|
|
23
|
+
state.lastSnapshotId = opts.remoteId;
|
|
24
|
+
if (ancestorKnown)
|
|
25
|
+
state.ancestorId = opts.remoteId;
|
|
26
|
+
for (const [sid, hash] of Object.entries(meta.sections)) {
|
|
27
|
+
if (typeof hash !== 'string' || hash === '')
|
|
28
|
+
continue;
|
|
29
|
+
state.sections[sid] = { hash, updatedAt: meta.createdAt };
|
|
30
|
+
}
|
|
31
|
+
state.transport = opts.transport;
|
|
32
|
+
await saveSyncState(opts.stateDir, state, opts.fsx);
|
|
33
|
+
opts.warnings.push(opts.msg(ancestorKnown ? 'sync.pushBaselineAdopted' : 'sync.pushBaselineAdoptedNoAncestor', {
|
|
34
|
+
remote: opts.remoteId,
|
|
35
|
+
base: opts.base,
|
|
36
|
+
}));
|
|
37
|
+
return opts.remoteId;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=baseline-heal.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SnapshotFs } from './fs.ts';
|
|
2
|
+
import type { RemoteSnapshotIndex } from './session-tombstones.ts';
|
|
3
|
+
import type { SyncTransport } from './transport.ts';
|
|
4
|
+
import type { MsgFunc } from '../core/messages.ts';
|
|
5
|
+
export interface PushBaseOptions {
|
|
6
|
+
stateDir: string;
|
|
7
|
+
fsx: SnapshotFs;
|
|
8
|
+
localSnapshotsDir?: string;
|
|
9
|
+
/** SYN-02:本轮已列过的远端 index(推进检测与墓碑继承共用同一份)。 */
|
|
10
|
+
index: RemoteSnapshotIndex;
|
|
11
|
+
transport: Pick<SyncTransport, 'type'> & {
|
|
12
|
+
ref: string;
|
|
13
|
+
};
|
|
14
|
+
hostname?: string;
|
|
15
|
+
msg: MsgFunc;
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}
|
|
18
|
+
export type PushBaseOutcome = {
|
|
19
|
+
ok: true;
|
|
20
|
+
base: string;
|
|
21
|
+
adopted?: string;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 判定本机能否继续推送,返回可用的基线。
|
|
28
|
+
*
|
|
29
|
+
* - 首次同步(没有基线)→ 放行;远端为空 → 放行(没有可比对的快照)。
|
|
30
|
+
* - 读不到远端列表 → **告警放行**(上传本身会再暴露通道问题),绝不把「读不到」当「没变」。
|
|
31
|
+
* - 远端最新快照就是当前基线 → 放行。
|
|
32
|
+
* - 远端最新快照是本机自己推的 → 收养为基线后放行(`adopted` 回传,调用方写进报告)。
|
|
33
|
+
* - 其余(别的设备的改动 / 没有 deviceId 的旧快照)→ 冲突拒绝,给 force 出口。
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolvePushBase(opts: PushBaseOptions): Promise<PushBaseOutcome>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* push 前置:远端是否已被别的设备推进,以及「是本机自己推的」时收养基线(0.4.1)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独成模块:这段判据是「推不推得上去」的唯一闸门,逻辑上只有三条出口
|
|
5
|
+
* (放行 / 告警放行 / 冲突拒绝),却要在 push 里挤掉二十多行 —— 抽出来后
|
|
6
|
+
* `sync-engine.push` 只剩「问一次闸门,拿到基线或冲突文案」。
|
|
7
|
+
*
|
|
8
|
+
* 事故形态(0.3.0 真机):transport.upload 已成功、recordBaseline 未执行 ⇒ 远端最新快照
|
|
9
|
+
* 就是本机自己那份,而基线还停在旧 id ⇒ 之后每轮都被判「远端被别的设备推进」永久拒绝,
|
|
10
|
+
* 每 60 s 一条失败,用户只能手改 sync-state。判据见 baseline-heal.ts:只有 deviceId 对得上
|
|
11
|
+
* 本机才收养,别的设备(或没有 deviceId 的旧快照)一律照旧拒绝。
|
|
12
|
+
*/
|
|
13
|
+
import os from 'node:os';
|
|
14
|
+
import { adoptOwnRemoteHead } from './baseline-heal.js';
|
|
15
|
+
import { loadSyncState } from './sync-state.js';
|
|
16
|
+
/**
|
|
17
|
+
* 判定本机能否继续推送,返回可用的基线。
|
|
18
|
+
*
|
|
19
|
+
* - 首次同步(没有基线)→ 放行;远端为空 → 放行(没有可比对的快照)。
|
|
20
|
+
* - 读不到远端列表 → **告警放行**(上传本身会再暴露通道问题),绝不把「读不到」当「没变」。
|
|
21
|
+
* - 远端最新快照就是当前基线 → 放行。
|
|
22
|
+
* - 远端最新快照是本机自己推的 → 收养为基线后放行(`adopted` 回传,调用方写进报告)。
|
|
23
|
+
* - 其余(别的设备的改动 / 没有 deviceId 的旧快照)→ 冲突拒绝,给 force 出口。
|
|
24
|
+
*/
|
|
25
|
+
export async function resolvePushBase(opts) {
|
|
26
|
+
const state = await loadSyncState(opts.stateDir, opts.fsx, opts.msg);
|
|
27
|
+
const base = state.lastSnapshotId;
|
|
28
|
+
if (base === '')
|
|
29
|
+
return { ok: true, base };
|
|
30
|
+
if (opts.index.reason !== undefined) {
|
|
31
|
+
opts.warnings.push(opts.msg('sync.pushAdvanceCheckFailed', { reason: opts.index.reason }));
|
|
32
|
+
return { ok: true, base };
|
|
33
|
+
}
|
|
34
|
+
const metas = opts.index.metas;
|
|
35
|
+
if (metas.length === 0)
|
|
36
|
+
return { ok: true, base };
|
|
37
|
+
const latest = metas[metas.length - 1].id; // list 按 createdAt 升序 → 最新在末
|
|
38
|
+
if (latest === base)
|
|
39
|
+
return { ok: true, base };
|
|
40
|
+
const adopted = await adoptOwnRemoteHead({
|
|
41
|
+
stateDir: opts.stateDir,
|
|
42
|
+
fsx: opts.fsx,
|
|
43
|
+
localSnapshotsDir: opts.localSnapshotsDir,
|
|
44
|
+
metas,
|
|
45
|
+
remoteId: latest,
|
|
46
|
+
base,
|
|
47
|
+
transport: opts.transport,
|
|
48
|
+
hostname: opts.hostname ?? os.hostname(),
|
|
49
|
+
msg: opts.msg,
|
|
50
|
+
warnings: opts.warnings,
|
|
51
|
+
});
|
|
52
|
+
if (adopted === null) {
|
|
53
|
+
// 无法安全断言「远端没变」时的保守拒绝:不 upload、不记基线、不改 sync-state。
|
|
54
|
+
return { ok: false, message: opts.msg('sync.pushRemoteAdvanced', { remote: latest, base }) };
|
|
55
|
+
}
|
|
56
|
+
return { ok: true, base: adopted, adopted };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=push-precheck.js.map
|
|
@@ -138,6 +138,15 @@ export interface SyncPushReport {
|
|
|
138
138
|
* 而不是记成「同步失败」。
|
|
139
139
|
*/
|
|
140
140
|
conflict?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* 本次推送前**收养了本机自己推上去的远端最新快照**(0.4.1 自愈):该值 = 被收养的快照 id。
|
|
143
|
+
*
|
|
144
|
+
* 触发场景:上次推送在上传成功、写基线之前被打断(进程退出/崩溃/断电),远端已前进而本机
|
|
145
|
+
* `lastSnapshotId` 仍是上一版 → 前置检测会永久拒绝推送(每次都说「远端被别人推进了」),
|
|
146
|
+
* 单设备用户因此被自己的快照锁死。判据只看「远端最新快照的 manifest.deviceId == 本机
|
|
147
|
+
* deviceId」,别的设备推进过就仍然按冲突返回,绝不越过。
|
|
148
|
+
*/
|
|
149
|
+
adoptedBase?: string;
|
|
141
150
|
}
|
|
142
151
|
/** 差异报告中的单个变更项(PlanItem 摘要,不含敏感细节) */
|
|
143
152
|
export interface PullChange {
|
|
@@ -516,18 +525,6 @@ export declare class SyncEngine {
|
|
|
516
525
|
private pruneRemoteSnapshots;
|
|
517
526
|
/** 读取远端保留策略;提供者缺失/抛错 → 缺省策略(保守多留,绝不因读取失败误删)。 */
|
|
518
527
|
private resolveRetentionPolicy;
|
|
519
|
-
/**
|
|
520
|
-
* push 前置:远端是否已被别的设备推进(防「推上去把别人的改动架空」)。
|
|
521
|
-
*
|
|
522
|
-
* 判据与 hasNewRemoteSnapshot() 同源但方向相反:
|
|
523
|
-
* - 首次同步(lastSnapshotId === '')→ **不拦**(本机没有基线可丢,第一次推送就是建立基线);
|
|
524
|
-
* - 远端为空 → 不拦(没有可比对的快照);
|
|
525
|
-
* - 其余:远端最新快照 id !== lastSnapshotId ⇒ 远端被推进(或本机基线已被裁剪)→ 拦。
|
|
526
|
-
* 两种情况都**无法安全断言「远端没变」**,保守拒绝并给出 force 出口。
|
|
527
|
-
* - list() 抛错 → 返回 reason(调用方按原样继续并告警),绝不把「读不到」当成「没变」。
|
|
528
|
-
* - SYN-02:index 可由 push() 传入(同一轮只列一次远端),缺省自己 list(其它调用点行为不变)。
|
|
529
|
-
*/
|
|
530
|
-
private remoteAdvancedCheck;
|
|
531
528
|
/**
|
|
532
529
|
* pull:拉取远端最新(或指定)快照 → 过滤 portable 分区 → 转临时标准 ZIP →
|
|
533
530
|
* 复用 Importer 预览流程(analyzeImport/createImportPlan)产出差异报告。
|
package/lib/sync/sync-engine.js
CHANGED
|
@@ -33,6 +33,7 @@ import { stringifyJsonSafe } from '../utils/json.js';
|
|
|
33
33
|
import { writeZip } from '../utils/zip.js';
|
|
34
34
|
import { createSnapshotFs, joinFs } from './fs.js';
|
|
35
35
|
import { writeSnapshotToDir } from './layout.js';
|
|
36
|
+
import { resolvePushBase } from './push-precheck.js';
|
|
36
37
|
import { credentialsMapFromYaml, decryptCredentialsPayload, decryptSectionsPayload, encryptCredentialsPayload, encryptSectionsPayload, } from './snapshot-crypto.js';
|
|
37
38
|
import { OPT_IN_SYNC_SECTIONS } from './sync-selection.js';
|
|
38
39
|
import { listRemoteSnapshotIndex, planSessionBookkeeping, remoteTombstonesOf, stripTombstonedSessionsInPlace, } from './session-tombstones.js';
|
|
@@ -64,6 +65,8 @@ const zh = {
|
|
|
64
65
|
'sync.applyMergeResolutionsNoImporter': 'applyMergeResolutions: SyncEngine 缺少 importer(需在 options 中注入)',
|
|
65
66
|
'sync.mergePendingConflicts': '仍有 {count} 个分区未裁决({sections}):已裁决的部分已写入本机,但基线不推进,冲突下一轮会重新出现',
|
|
66
67
|
'sync.baselineRexportFailed': '写回成功但重新导出本机分区失败({sections}):无法证明基线与本机一致,本次**不记基线**(远端指针保持原值,下一轮重新合并收敛)',
|
|
68
|
+
'sync.pushBaselineAdopted': '远端最新快照 {remote} 是本机上次推送的(本机基线停在 {base},上次推送在记录基线前被打断):已把它收养为基线并继续本次推送',
|
|
69
|
+
'sync.pushBaselineAdoptedNoAncestor': '远端最新快照 {remote} 是本机上次推送的,但本机没有它的本地祖先副本:已收养基线(下次合并退化为两方合并,结果仍安全)',
|
|
67
70
|
};
|
|
68
71
|
const en = {
|
|
69
72
|
'sync.pushRemoteAdvanced': 'The newest remote snapshot {remote} differs from the local baseline {base}: this push did not run (nothing written remotely, baseline untouched). Sync the remote changes first, or explicitly force the push if this machine should overwrite the remote.',
|
|
@@ -72,6 +75,8 @@ const en = {
|
|
|
72
75
|
'sync.applyMergeResolutionsNoImporter': 'applyMergeResolutions: SyncEngine is missing the importer (must be injected via options)',
|
|
73
76
|
'sync.mergePendingConflicts': '{count} section(s) still have no decision ({sections}): the decided parts were written locally, but the baseline is not advanced, so the conflicts will reappear next round',
|
|
74
77
|
'sync.baselineRexportFailed': 'The write succeeded but re-exporting the local section(s) failed ({sections}): the baseline cannot be proven to match this machine, so no baseline was recorded (the remote pointer keeps its old value and the next merge converges again)',
|
|
78
|
+
'sync.pushBaselineAdopted': 'The newest remote snapshot {remote} was pushed by this device (its baseline stopped at {base}: that push was interrupted before recording the baseline): the baseline has been adopted and this push continues',
|
|
79
|
+
'sync.pushBaselineAdoptedNoAncestor': 'The newest remote snapshot {remote} was pushed by this device, but no local ancestor copy exists for it: the baseline has been adopted (the next merge degrades to a two-way merge, which is still safe)',
|
|
75
80
|
};
|
|
76
81
|
registerMessageCatalog({ id: 'sync-engine-merge', zh, en });
|
|
77
82
|
/** plan 的单个分区结果 → 预览视图(三侧都只回传可读文本,绝不回传原始值)。 */
|
|
@@ -478,6 +483,8 @@ export class SyncEngine {
|
|
|
478
483
|
*/
|
|
479
484
|
async push(opts = {}) {
|
|
480
485
|
const warnings = [];
|
|
486
|
+
/** 0.4.1:本次推送前收养的「本机自己推的」远端快照(非空 ⇒ 上次推送被打断过,已在报告里如实回传) */
|
|
487
|
+
let adopted;
|
|
481
488
|
const includeSecrets = opts.includeSecrets ?? false;
|
|
482
489
|
const encrypt = opts.encrypt ?? false;
|
|
483
490
|
// 安全不变量:导出密钥必须加密;加密必须给密码(密码绝不落盘)
|
|
@@ -490,24 +497,17 @@ export class SyncEngine {
|
|
|
490
497
|
// SYN-02:本轮只列一次远端 index(推进检测 + 继承会话删除墓碑共用;墓碑累积在最新快照里)
|
|
491
498
|
const remoteIndex = await listRemoteSnapshotIndex(this.transport);
|
|
492
499
|
const remoteTombstones = remoteIndex.reason === undefined ? remoteTombstonesOf(remoteIndex.metas) : [];
|
|
493
|
-
//
|
|
494
|
-
//
|
|
500
|
+
// 远端推进检测(判据与 0.4.1 自愈收养全在 push-precheck.ts);冲突时**不抛错**、
|
|
501
|
+
// 不 upload、不记基线、不改 sync-state,只把文案回给调用方走 force 出口。
|
|
495
502
|
if (opts.force !== true) {
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return {
|
|
503
|
-
|
|
504
|
-
snapshotId: '',
|
|
505
|
-
sections: [],
|
|
506
|
-
warnings,
|
|
507
|
-
conflict: true,
|
|
508
|
-
message: this.msg('sync.pushRemoteAdvanced', { remote: check.latest, base: check.base }),
|
|
509
|
-
};
|
|
510
|
-
}
|
|
503
|
+
const pre = await resolvePushBase({
|
|
504
|
+
stateDir: this.stateDir, fsx: this.fsx, localSnapshotsDir: this.localSnapshotsDir,
|
|
505
|
+
index: remoteIndex, transport: { type: this.transport.type, ref: this.transportRef },
|
|
506
|
+
msg: this.msg, warnings,
|
|
507
|
+
});
|
|
508
|
+
if (!pre.ok)
|
|
509
|
+
return { ok: false, snapshotId: '', sections: [], warnings, conflict: true, message: pre.message };
|
|
510
|
+
adopted = pre.adopted;
|
|
511
511
|
}
|
|
512
512
|
const plainSections = {};
|
|
513
513
|
const targets = this.pushTargets(opts.sections, warnings);
|
|
@@ -607,7 +607,13 @@ export class SyncEngine {
|
|
|
607
607
|
? { sessionUnits: bookkeeping.sessionUnits, deletedSessions: bookkeeping.tombstones }
|
|
608
608
|
: {}),
|
|
609
609
|
});
|
|
610
|
-
return {
|
|
610
|
+
return {
|
|
611
|
+
ok: true,
|
|
612
|
+
snapshotId: id,
|
|
613
|
+
sections: Object.keys(plainSections),
|
|
614
|
+
warnings,
|
|
615
|
+
...(adopted !== undefined ? { adoptedBase: adopted } : {}),
|
|
616
|
+
};
|
|
611
617
|
}
|
|
612
618
|
/**
|
|
613
619
|
* P0-②:push 前只读预览「将推送什么」—— 零写入、零远端变更:
|
|
@@ -806,31 +812,6 @@ export class SyncEngine {
|
|
|
806
812
|
return DEFAULT_RETENTION_POLICY;
|
|
807
813
|
}
|
|
808
814
|
}
|
|
809
|
-
/**
|
|
810
|
-
* push 前置:远端是否已被别的设备推进(防「推上去把别人的改动架空」)。
|
|
811
|
-
*
|
|
812
|
-
* 判据与 hasNewRemoteSnapshot() 同源但方向相反:
|
|
813
|
-
* - 首次同步(lastSnapshotId === '')→ **不拦**(本机没有基线可丢,第一次推送就是建立基线);
|
|
814
|
-
* - 远端为空 → 不拦(没有可比对的快照);
|
|
815
|
-
* - 其余:远端最新快照 id !== lastSnapshotId ⇒ 远端被推进(或本机基线已被裁剪)→ 拦。
|
|
816
|
-
* 两种情况都**无法安全断言「远端没变」**,保守拒绝并给出 force 出口。
|
|
817
|
-
* - list() 抛错 → 返回 reason(调用方按原样继续并告警),绝不把「读不到」当成「没变」。
|
|
818
|
-
* - SYN-02:index 可由 push() 传入(同一轮只列一次远端),缺省自己 list(其它调用点行为不变)。
|
|
819
|
-
*/
|
|
820
|
-
async remoteAdvancedCheck(index) {
|
|
821
|
-
const state = await loadSyncState(this.stateDir, this.fsx, this.msg);
|
|
822
|
-
const base = state.lastSnapshotId;
|
|
823
|
-
if (base === '')
|
|
824
|
-
return { blocked: false, base, latest: '' };
|
|
825
|
-
const listed = index ?? await listRemoteSnapshotIndex(this.transport);
|
|
826
|
-
if (listed.reason !== undefined)
|
|
827
|
-
return { blocked: false, base, latest: '', reason: listed.reason };
|
|
828
|
-
const metas = listed.metas;
|
|
829
|
-
if (metas.length === 0)
|
|
830
|
-
return { blocked: false, base, latest: '' };
|
|
831
|
-
const latest = metas[metas.length - 1].id; // list 按 createdAt 升序 → 最新在末
|
|
832
|
-
return { blocked: latest !== base, base, latest };
|
|
833
|
-
}
|
|
834
815
|
/**
|
|
835
816
|
* pull:拉取远端最新(或指定)快照 → 过滤 portable 分区 → 转临时标准 ZIP →
|
|
836
817
|
* 复用 Importer 预览流程(analyzeImport/createImportPlan)产出差异报告。
|
package/lib/ui/history-model.js
CHANGED
|
@@ -4,7 +4,8 @@ export function resultBadgeKind(result) {
|
|
|
4
4
|
return 'ok';
|
|
5
5
|
if (result === 'failed')
|
|
6
6
|
return 'error';
|
|
7
|
-
|
|
7
|
+
// pending(0.4.1)= 跑完了但还有待裁决项:绝不当成失败(红),也不是跳过 —— 用琥珀告警色
|
|
8
|
+
return 'warn'; // skipped / pending
|
|
8
9
|
}
|
|
9
10
|
export function kindLabelKey(kind) {
|
|
10
11
|
return `history.kind.${kind}`;
|
|
@@ -17,7 +18,7 @@ export const HISTORY_KIND_OPTIONS = [
|
|
|
17
18
|
'backup', 'backup-manual', 'snapshot-delete', 'snapshot-prune',
|
|
18
19
|
];
|
|
19
20
|
/** 结果过滤选项。 */
|
|
20
|
-
export const HISTORY_RESULT_OPTIONS = ['success', '
|
|
21
|
+
export const HISTORY_RESULT_OPTIONS = ['success', 'pending', 'skipped', 'failed'];
|
|
21
22
|
/** 把 UI 过滤模型转为后端 query 参数(kind/recent 转 kinds/recent 语义)。 */
|
|
22
23
|
export function filterToQuery(f) {
|
|
23
24
|
const q = {};
|
|
@@ -40,7 +40,7 @@ export interface OverviewSyncLite {
|
|
|
40
40
|
export interface OverviewHistoryLite {
|
|
41
41
|
at: string;
|
|
42
42
|
kind: string;
|
|
43
|
-
result: 'success' | 'failed' | 'skipped';
|
|
43
|
+
result: 'success' | 'failed' | 'skipped' | 'pending';
|
|
44
44
|
summary: string;
|
|
45
45
|
}
|
|
46
46
|
/** Overview 数据输入(null = 未加载/加载失败;组件逐项就绪逐项传入)。 */
|
|
@@ -124,8 +124,8 @@ export declare function overviewHealth(inputs: OverviewInputs): OverviewHealth;
|
|
|
124
124
|
export declare function overviewKindKey(kind: string): string;
|
|
125
125
|
export interface OverviewActivityItem {
|
|
126
126
|
at: string;
|
|
127
|
-
/** 徽章语义(success→ok / failed→error / skipped→warn,与 history-model 同判定)。 */
|
|
128
|
-
badge: 'ok' | 'error' | 'warn';
|
|
127
|
+
/** 徽章语义(success→ok / failed→error / skipped→warn / pending→pending,与 history-model 同判定)。 */
|
|
128
|
+
badge: 'ok' | 'error' | 'warn' | 'pending';
|
|
129
129
|
/** UI 渲染 key(`overview.kind.<kind>`;未知 kind 归一为 other → `overview.kind.other`)。 */
|
|
130
130
|
kindKey: string;
|
|
131
131
|
/** 原始摘要(上层渲染前 redact())。 */
|
package/lib/ui/overview-view.js
CHANGED
|
@@ -199,7 +199,15 @@ export function overviewActivity(history, limit = 5) {
|
|
|
199
199
|
});
|
|
200
200
|
return sorted.slice(0, limit).map((e) => ({
|
|
201
201
|
at: e.at,
|
|
202
|
-
badge: e.result === 'success'
|
|
202
|
+
badge: e.result === 'success'
|
|
203
|
+
? 'ok'
|
|
204
|
+
: e.result === 'failed'
|
|
205
|
+
? 'error'
|
|
206
|
+
// pending:跑完了但仍有待裁决项(自动同步下行冲突未裁决)—— 首页必须说「待裁决」,
|
|
207
|
+
// 既不能红成「失败」,也不该混进「跳过」(那一轮确有上传/应用发生)
|
|
208
|
+
: e.result === 'pending'
|
|
209
|
+
? 'pending'
|
|
210
|
+
: 'warn',
|
|
203
211
|
kindKey: overviewKindKey(e.kind),
|
|
204
212
|
summary: e.summary,
|
|
205
213
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-config-manager",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Backup, restore, export, import, migrate and sync your DeepSeek Harness (DSH) configuration: settings, plugins, MCP servers, skills, agent presets and workspaces. One-click migration to another machine. DSH 配置一键备份、恢复、导出、导入、迁移与同步插件。",
|
|
6
6
|
"icon": "./icon.svg",
|
|
@@ -101,6 +101,7 @@ export const zh = {
|
|
|
101
101
|
'history.result.success': '成功',
|
|
102
102
|
'history.result.failed': '失败',
|
|
103
103
|
'history.result.skipped': '跳过',
|
|
104
|
+
'history.result.pending': '待裁决',
|
|
104
105
|
} as const satisfies Record<HistoryKey, string>;
|
|
105
106
|
|
|
106
107
|
export const en = {
|
|
@@ -158,5 +159,6 @@ export const en = {
|
|
|
158
159
|
'history.result.success': 'Success',
|
|
159
160
|
'history.result.failed': 'Failed',
|
|
160
161
|
'history.result.skipped': 'Skipped',
|
|
162
|
+
'history.result.pending': 'Needs decision',
|
|
161
163
|
} as const satisfies Record<HistoryKey, string>;
|
|
162
164
|
|
|
@@ -372,11 +372,17 @@ export function HomePanel({ api, syncApi, historyApi, t, syncT, openForeignImpor
|
|
|
372
372
|
/** 某指标段是否仍在等数据:同步段只看自己的加载态,其余三段/四段看首屏快请求。 */
|
|
373
373
|
const segLoading = (key: OverviewMetricKey): boolean => (key === 'sync' ? syncState === 'loading' : loading)
|
|
374
374
|
|
|
375
|
-
/** 结果渲染:ok = 绿点(降噪);failed/skipped = 徽章(需要被看见)。 */
|
|
376
|
-
const resultNode = (badge: 'ok' | 'error' | 'warn'): ReactNode =>
|
|
375
|
+
/** 结果渲染:ok = 绿点(降噪);failed/skipped/pending = 徽章(需要被看见)。 */
|
|
376
|
+
const resultNode = (badge: 'ok' | 'error' | 'warn' | 'pending'): ReactNode =>
|
|
377
377
|
badge === 'ok'
|
|
378
378
|
? <span className={css.activityResultOk}><StatusDot kind="ok" />{t('overview.result.success')}</span>
|
|
379
|
-
: <Badge kind={badge
|
|
379
|
+
: <Badge kind={badge === 'error' ? 'error' : 'warn'}>{
|
|
380
|
+
badge === 'error'
|
|
381
|
+
? t('overview.result.failed')
|
|
382
|
+
: badge === 'pending'
|
|
383
|
+
? t('overview.result.pending')
|
|
384
|
+
: t('overview.result.skipped')
|
|
385
|
+
}</Badge>
|
|
380
386
|
|
|
381
387
|
return (
|
|
382
388
|
<div className={css.viewBody}>
|
package/src/client/locales.ts
CHANGED
|
@@ -693,6 +693,7 @@ export const zh = {
|
|
|
693
693
|
'overview.result.success': '成功',
|
|
694
694
|
'overview.result.failed': '失败',
|
|
695
695
|
'overview.result.skipped': '跳过',
|
|
696
|
+
'overview.result.pending': '待裁决',
|
|
696
697
|
'overview.activity.copy': '复制',
|
|
697
698
|
'overview.activity.redacted': '(文件名已脱敏)',
|
|
698
699
|
'overview.sections.entries': '{count} 项',
|
|
@@ -1581,6 +1582,7 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
1581
1582
|
'overview.result.success': 'OK',
|
|
1582
1583
|
'overview.result.failed': 'Failed',
|
|
1583
1584
|
'overview.result.skipped': 'Skipped',
|
|
1585
|
+
'overview.result.pending': 'Needs decision',
|
|
1584
1586
|
'overview.activity.copy': 'Copy',
|
|
1585
1587
|
'overview.activity.redacted': '(filename redacted)',
|
|
1586
1588
|
'overview.sections.entries': '{count} {count, plural, item|items}',
|
|
@@ -109,6 +109,9 @@ export function skipReasonKey(reason: string | undefined): SyncKey | null {
|
|
|
109
109
|
// 真·自动同步(conflictPolicy='local'):冲突已按策略「保留本机并推上去」消解,
|
|
110
110
|
// 远端那一版被覆盖(仍在远端历史快照里,可回滚)—— 必须与「冲突待裁决」分开说。
|
|
111
111
|
case 'conflict-kept-local': return 'history.autosyncReasonConflictKeptLocal';
|
|
112
|
+
// 0.4.1:推送前收养了本机自己推的远端快照(上次推送在写基线前被打断)—— 结果仍是 success,
|
|
113
|
+
// 这条原因只是把「基线是被修好的」讲明白。
|
|
114
|
+
case 'baseline-adopted': return 'history.autosyncReasonBaselineAdopted';
|
|
112
115
|
// 未知原因:没有字典键(调用方决定回退策略)
|
|
113
116
|
default: return null;
|
|
114
117
|
}
|