zen-fs-config 0.7.13 → 0.7.15
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/dist/index.d.mts +224 -1
- package/dist/index.d.ts +224 -1
- package/dist/index.js +493 -38
- package/dist/index.mjs +483 -38
- package/dist/zen-fs-config.js +483 -38
- package/package.json +1 -1
package/dist/zen-fs-config.js
CHANGED
|
@@ -25468,6 +25468,8 @@ var ZenFSConfig = (() => {
|
|
|
25468
25468
|
TombstoneStore: () => TombstoneStore,
|
|
25469
25469
|
VERSIONS_DIR: () => VERSIONS_DIR,
|
|
25470
25470
|
VersionStore: () => VersionStore,
|
|
25471
|
+
bindRemoteGroupIdentity: () => bindRemoteGroupIdentity,
|
|
25472
|
+
bindRemoteGroupIdentityDetailed: () => bindRemoteGroupIdentityDetailed,
|
|
25471
25473
|
configKeyToFilePath: () => configKeyToFilePath,
|
|
25472
25474
|
connect: () => connect,
|
|
25473
25475
|
createBackend: () => createBackend,
|
|
@@ -25475,6 +25477,7 @@ var ZenFSConfig = (() => {
|
|
|
25475
25477
|
createSerializerChain: () => createSerializerChain,
|
|
25476
25478
|
dataGroupLocalStoreName: () => dataGroupLocalStoreName,
|
|
25477
25479
|
deleteDataGroupLocalStore: () => deleteDataGroupLocalStore,
|
|
25480
|
+
deleteIndexedDbStore: () => deleteIndexedDbStore,
|
|
25478
25481
|
encodeMetaPath: () => encodeMetaPath,
|
|
25479
25482
|
getAccountFields: () => getAccountFields,
|
|
25480
25483
|
getBackendMetadata: () => getBackendMetadata,
|
|
@@ -25485,20 +25488,27 @@ var ZenFSConfig = (() => {
|
|
|
25485
25488
|
isKeepFile: () => isKeepFile,
|
|
25486
25489
|
isLocalStorageUnavailableError: () => isLocalStorageUnavailableError,
|
|
25487
25490
|
isMtimeSidecar: () => isMtimeSidecar,
|
|
25491
|
+
isValidGroupInstanceId: () => isValidGroupInstanceId,
|
|
25488
25492
|
legacyVersionPathFor: () => legacyVersionPathFor,
|
|
25489
25493
|
listBackendMetadata: () => listBackendMetadata,
|
|
25490
25494
|
listBackends: () => listBackends,
|
|
25491
25495
|
localPrimaryType: () => localPrimaryType,
|
|
25496
|
+
localSyncStoreNames: () => localSyncStoreNames,
|
|
25492
25497
|
mergeAccountFields: () => mergeAccountFields,
|
|
25493
25498
|
migrateVersionSidecars: () => migrateVersionSidecars,
|
|
25499
|
+
newGroupInstanceId: () => newGroupInstanceId,
|
|
25494
25500
|
purgeKeepFiles: () => purgeKeepFiles,
|
|
25501
|
+
purgeLocalSyncConfig: () => purgeLocalSyncConfig,
|
|
25495
25502
|
purgeMtimeSidecars: () => purgeMtimeSidecars,
|
|
25496
25503
|
readGroupDescriptor: () => readGroupDescriptor,
|
|
25497
25504
|
readVersion: () => readVersion,
|
|
25498
25505
|
registerBackend: () => registerBackend,
|
|
25499
25506
|
registerFolderBackend: () => registerFolderBackend,
|
|
25500
25507
|
resolveLocalPrimary: () => resolveLocalPrimary,
|
|
25508
|
+
resolveRemoteIdentity: () => resolveRemoteIdentity,
|
|
25501
25509
|
sha256: () => sha256,
|
|
25510
|
+
shortInstanceId: () => shortInstanceId,
|
|
25511
|
+
summarizeIdentity: () => summarizeIdentity,
|
|
25502
25512
|
unregisterBackend: () => unregisterBackend,
|
|
25503
25513
|
verifyOrRepairVersion: () => verifyOrRepairVersion,
|
|
25504
25514
|
versionPathFor: () => versionPathFor,
|
|
@@ -27999,6 +28009,28 @@ var ZenFSConfig = (() => {
|
|
|
27999
28009
|
const { updatedAt: _ignored, ...rest } = parsed;
|
|
28000
28010
|
return rest;
|
|
28001
28011
|
}
|
|
28012
|
+
function isNotFoundError(err2) {
|
|
28013
|
+
const e = err2;
|
|
28014
|
+
if (!e) return false;
|
|
28015
|
+
if (e.code === "ENOENT" || e.code === "ENOTDIR" || e.name === "NotFoundError" || e.errno === -2) return true;
|
|
28016
|
+
return /no such file|not found|不存在/i.test(String(e.message ?? ""));
|
|
28017
|
+
}
|
|
28018
|
+
async function readGroupDescriptorStrict(fs) {
|
|
28019
|
+
let raw;
|
|
28020
|
+
try {
|
|
28021
|
+
raw = new TextDecoder().decode(toBytes(await fs.readFile(GROUP_DESCRIPTOR_FILE2)));
|
|
28022
|
+
} catch (err2) {
|
|
28023
|
+
if (isNotFoundError(err2)) return null;
|
|
28024
|
+
throw err2;
|
|
28025
|
+
}
|
|
28026
|
+
try {
|
|
28027
|
+
const parsed = JSON.parse(raw);
|
|
28028
|
+
const { updatedAt: _ignored, ...rest } = parsed;
|
|
28029
|
+
return rest;
|
|
28030
|
+
} catch {
|
|
28031
|
+
return null;
|
|
28032
|
+
}
|
|
28033
|
+
}
|
|
28002
28034
|
async function writeGroupDescriptor(fs, descriptor) {
|
|
28003
28035
|
const bytes = serializeGroupDescriptor(descriptor);
|
|
28004
28036
|
if (await readText(fs, GROUP_DESCRIPTOR_FILE2) === bytes) return;
|
|
@@ -28407,20 +28439,62 @@ var ZenFSConfig = (() => {
|
|
|
28407
28439
|
return typeof value === "string" && INSTANCE_ID_RE.test(value.trim());
|
|
28408
28440
|
}
|
|
28409
28441
|
async function bindRemoteGroupIdentity(remoteFS, identity) {
|
|
28442
|
+
const result = await bindRemoteGroupIdentityDetailed(remoteFS, identity);
|
|
28443
|
+
return result.state;
|
|
28444
|
+
}
|
|
28445
|
+
function summarizeIdentity(identity) {
|
|
28446
|
+
if (!identity) return "\uFF08\u65E0\u63CF\u8FF0\u7B26\uFF09";
|
|
28447
|
+
const parts = [
|
|
28448
|
+
`kind=${identity.kind ?? "?"}`,
|
|
28449
|
+
`id=${identity.id ?? "?"}`,
|
|
28450
|
+
`\u5B9E\u4F8B ID=${identity.instanceId ? shortInstanceId(identity.instanceId) : "\uFF08\u65E0\uFF09"}`
|
|
28451
|
+
];
|
|
28452
|
+
return parts.join(" \xB7 ");
|
|
28453
|
+
}
|
|
28454
|
+
function shortInstanceId(instanceId) {
|
|
28455
|
+
return `${instanceId.slice(0, 8)}\u2026`;
|
|
28456
|
+
}
|
|
28457
|
+
function snapshotOf(descriptor) {
|
|
28458
|
+
if (!descriptor) return null;
|
|
28459
|
+
return {
|
|
28460
|
+
kind: descriptor.kind,
|
|
28461
|
+
id: descriptor.id,
|
|
28462
|
+
instanceId: pickInstanceId(descriptor),
|
|
28463
|
+
...descriptor.name ? { name: descriptor.name } : {}
|
|
28464
|
+
};
|
|
28465
|
+
}
|
|
28466
|
+
async function bindRemoteGroupIdentityDetailed(remoteFS, identity) {
|
|
28410
28467
|
let remote = null;
|
|
28411
28468
|
try {
|
|
28412
|
-
remote = await
|
|
28469
|
+
remote = await readGroupDescriptorStrict(remoteFS);
|
|
28413
28470
|
} catch (err2) {
|
|
28414
28471
|
log8.warn(`[GroupIdentity] failed to read remote ${identity.kind}/"${identity.id}" group.json:`, err2);
|
|
28415
|
-
|
|
28472
|
+
return {
|
|
28473
|
+
state: "conflict",
|
|
28474
|
+
remote: null,
|
|
28475
|
+
local: identity,
|
|
28476
|
+
conflict: "unreadable",
|
|
28477
|
+
unreadable: true,
|
|
28478
|
+
error: err2?.message ?? String(err2)
|
|
28479
|
+
};
|
|
28480
|
+
}
|
|
28481
|
+
const snapshot = snapshotOf(remote);
|
|
28482
|
+
const current = snapshot?.instanceId;
|
|
28483
|
+
if (snapshot?.kind && snapshot.kind !== identity.kind) {
|
|
28484
|
+
log8.warn(
|
|
28485
|
+
`[GroupIdentity] remote kind "${snapshot.kind}" \u2260 this group kind "${identity.kind}" \u2014 sync pair NOT created`
|
|
28486
|
+
);
|
|
28487
|
+
return { state: "conflict", remote: snapshot, local: identity, conflict: "kind-mismatch" };
|
|
28416
28488
|
}
|
|
28417
|
-
const current = remote?.instanceId;
|
|
28418
28489
|
if (isValidGroupInstanceId(current)) {
|
|
28419
|
-
if (current === identity.instanceId)
|
|
28490
|
+
if (current === identity.instanceId) {
|
|
28491
|
+
return { state: "match", remote: snapshot, local: identity };
|
|
28492
|
+
}
|
|
28493
|
+
const reason = snapshot?.id && snapshot.id !== identity.id ? "id-mismatch" : "instance-mismatch";
|
|
28420
28494
|
log8.warn(
|
|
28421
|
-
`[GroupIdentity] backend belongs to another sync group (remote
|
|
28495
|
+
`[GroupIdentity] backend belongs to another sync group (remote ${summarizeIdentity(snapshot)}, this group ${summarizeIdentity(identity)}) \u2014 sync pair NOT created`
|
|
28422
28496
|
);
|
|
28423
|
-
return "conflict";
|
|
28497
|
+
return { state: "conflict", remote: snapshot, local: identity, conflict: reason };
|
|
28424
28498
|
}
|
|
28425
28499
|
const next = {
|
|
28426
28500
|
schemaVersion: 2,
|
|
@@ -28430,22 +28504,79 @@ var ZenFSConfig = (() => {
|
|
|
28430
28504
|
...remote?.name ?? identity.name ? { name: remote?.name ?? identity.name } : {},
|
|
28431
28505
|
...remote?.features ?? identity.features ? { features: remote?.features ?? identity.features } : {}
|
|
28432
28506
|
};
|
|
28433
|
-
if (next.kind !== identity.kind) {
|
|
28434
|
-
log8.warn(
|
|
28435
|
-
`[GroupIdentity] remote kind "${next.kind}" \u2260 this group kind "${identity.kind}" \u2014 sync pair NOT created`
|
|
28436
|
-
);
|
|
28437
|
-
return "conflict";
|
|
28438
|
-
}
|
|
28439
28507
|
try {
|
|
28440
28508
|
await writeGroupDescriptor(remoteFS, next);
|
|
28441
28509
|
} catch (err2) {
|
|
28442
28510
|
log8.warn(`[GroupIdentity] failed to claim remote root for "${identity.id}":`, err2);
|
|
28443
|
-
return
|
|
28511
|
+
return {
|
|
28512
|
+
state: "conflict",
|
|
28513
|
+
remote: snapshot,
|
|
28514
|
+
local: identity,
|
|
28515
|
+
conflict: "claim-failed",
|
|
28516
|
+
error: err2?.message ?? String(err2)
|
|
28517
|
+
};
|
|
28444
28518
|
}
|
|
28445
28519
|
log8.log(
|
|
28446
28520
|
`[GroupIdentity] claimed remote root for ${identity.kind}/"${identity.id}" (instanceId=${identity.instanceId})`
|
|
28447
28521
|
);
|
|
28448
|
-
return "claimed";
|
|
28522
|
+
return { state: "claimed", remote: snapshot, local: identity };
|
|
28523
|
+
}
|
|
28524
|
+
async function resolveRemoteIdentity(remoteFS, identity, mode) {
|
|
28525
|
+
let remote = null;
|
|
28526
|
+
try {
|
|
28527
|
+
remote = await readGroupDescriptorStrict(remoteFS);
|
|
28528
|
+
} catch (err2) {
|
|
28529
|
+
return { mode, ok: false, reason: `\u8FDC\u7AEF\u63CF\u8FF0\u7B26\u8BFB\u4E0D\u5230\uFF1A${err2?.message ?? String(err2)}` };
|
|
28530
|
+
}
|
|
28531
|
+
const snapshot = snapshotOf(remote);
|
|
28532
|
+
if (mode === "adopt-remote-instance") {
|
|
28533
|
+
const remoteInstanceId = snapshot?.instanceId;
|
|
28534
|
+
if (!isValidGroupInstanceId(remoteInstanceId)) {
|
|
28535
|
+
return { mode, ok: false, reason: "\u8FDC\u7AEF\u6CA1\u6709\u5B9E\u4F8B\u8EAB\u4EFD\uFF0C\u65E0\u9700\u5BF9\u9F50", remote: snapshot };
|
|
28536
|
+
}
|
|
28537
|
+
if (snapshot?.kind !== identity.kind) {
|
|
28538
|
+
return {
|
|
28539
|
+
mode,
|
|
28540
|
+
ok: false,
|
|
28541
|
+
reason: `\u8FDC\u7AEF kind=${snapshot?.kind ?? "?"}\uFF0C\u672C\u7EC4 kind=${identity.kind}\uFF1A\u7C7B\u578B\u4E0D\u540C\u4E0D\u80FD\u53EA\u5BF9\u9F50\u5B9E\u4F8B\u8EAB\u4EFD`,
|
|
28542
|
+
remote: snapshot
|
|
28543
|
+
};
|
|
28544
|
+
}
|
|
28545
|
+
if (snapshot?.id !== identity.id) {
|
|
28546
|
+
return {
|
|
28547
|
+
mode,
|
|
28548
|
+
ok: false,
|
|
28549
|
+
reason: `\u8FDC\u7AEF id=${snapshot?.id ?? "?"}\uFF0C\u672C\u7EC4 id=${identity.id}\uFF1A\u7EC4 id \u4E0D\u540C\u8BF4\u660E\u8FDC\u7AEF\u6839\u88AB\u53E6\u4E00\u4E2A\u903B\u8F91\u7EC4\u5360\u7528\uFF0C\u4E0D\u80FD\u5BF9\u9F50`,
|
|
28550
|
+
remote: snapshot
|
|
28551
|
+
};
|
|
28552
|
+
}
|
|
28553
|
+
return { mode, ok: true, instanceId: remoteInstanceId, remote: snapshot };
|
|
28554
|
+
}
|
|
28555
|
+
if (snapshot && snapshot.kind !== identity.kind) {
|
|
28556
|
+
return {
|
|
28557
|
+
mode,
|
|
28558
|
+
ok: false,
|
|
28559
|
+
reason: `\u8FDC\u7AEF kind=${snapshot.kind}\uFF0C\u672C\u7EC4 kind=${identity.kind}\uFF1A\u7C7B\u578B\u4E0D\u540C\u4E0D\u5141\u8BB8\u6539\u5199\u8FDC\u7AEF`,
|
|
28560
|
+
remote: snapshot
|
|
28561
|
+
};
|
|
28562
|
+
}
|
|
28563
|
+
const next = {
|
|
28564
|
+
schemaVersion: 2,
|
|
28565
|
+
kind: identity.kind,
|
|
28566
|
+
id: identity.id,
|
|
28567
|
+
instanceId: identity.instanceId,
|
|
28568
|
+
...identity.name ? { name: identity.name } : {},
|
|
28569
|
+
...identity.features ? { features: identity.features } : {}
|
|
28570
|
+
};
|
|
28571
|
+
try {
|
|
28572
|
+
await writeGroupDescriptor(remoteFS, next);
|
|
28573
|
+
} catch (err2) {
|
|
28574
|
+
return { mode, ok: false, reason: `\u5199\u8FDC\u7AEF\u5931\u8D25\uFF1A${err2?.message ?? String(err2)}`, remote: snapshot };
|
|
28575
|
+
}
|
|
28576
|
+
log8.log(
|
|
28577
|
+
`[GroupIdentity] rewrote remote identity to ${identity.kind}/"${identity.id}" (instanceId=${identity.instanceId})`
|
|
28578
|
+
);
|
|
28579
|
+
return { mode, ok: true, remote: snapshot };
|
|
28449
28580
|
}
|
|
28450
28581
|
function pickInstanceId(descriptor) {
|
|
28451
28582
|
const value = descriptor?.instanceId;
|
|
@@ -28696,6 +28827,24 @@ var ZenFSConfig = (() => {
|
|
|
28696
28827
|
}
|
|
28697
28828
|
|
|
28698
28829
|
// src/config-repo.ts
|
|
28830
|
+
function describeConflict(result) {
|
|
28831
|
+
const remote = summarizeIdentity(result.remote);
|
|
28832
|
+
const local = summarizeIdentity(result.local);
|
|
28833
|
+
switch (result.conflict) {
|
|
28834
|
+
case "kind-mismatch":
|
|
28835
|
+
return `\u7EC4\u7C7B\u578B\u4E0D\u4E00\u81F4\uFF1A\u8FDC\u7AEF ${remote}\uFF0C\u672C\u7EC4 ${local}\u3002\u8BE5\u8FDC\u7AEF\u6839\u5DF2\u88AB\u53E6\u4E00\u7C7B\u7EC4\u5360\u7528\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF`;
|
|
28836
|
+
case "id-mismatch":
|
|
28837
|
+
return `\u7EC4 id \u4E0D\u4E00\u81F4\uFF1A\u8FDC\u7AEF ${remote}\uFF0C\u672C\u7EC4 ${local}\u3002\u540C\u4E00\u8FDC\u7AEF\u6839\u88AB\u53E6\u4E00\u4E2A\u903B\u8F91\u7EC4\u5360\u7528\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF`;
|
|
28838
|
+
case "instance-mismatch":
|
|
28839
|
+
return `\u5B9E\u4F8B\u8EAB\u4EFD\u4E0D\u4E00\u81F4\uFF1A\u8FDC\u7AEF ${remote}\uFF0C\u672C\u7EC4 ${local}\u3002\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF\uFF08\u786E\u8BA4\u540E\u53EF\u5728\u754C\u9762\u4E0A\u5BF9\u9F50\uFF09`;
|
|
28840
|
+
case "unreadable":
|
|
28841
|
+
return `\u8FDC\u7AEF group.json \u8BFB\u4E0D\u5230\uFF08${result.error ?? "\u672A\u77E5\u9519\u8BEF"}\uFF09\uFF0C\u65E0\u6CD5\u5224\u65AD\u5F52\u5C5E\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF`;
|
|
28842
|
+
case "claim-failed":
|
|
28843
|
+
return `\u8BA4\u9886\u8FDC\u7AEF\u6839\u5931\u8D25\uFF08${result.error ?? "\u672A\u77E5\u9519\u8BEF"}\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF`;
|
|
28844
|
+
default:
|
|
28845
|
+
return `\u8FDC\u7AEF\u6839\u5F52\u5C5E\u51B2\u7A81\uFF1A\u8FDC\u7AEF ${remote}\uFF0C\u672C\u7EC4 ${local}`;
|
|
28846
|
+
}
|
|
28847
|
+
}
|
|
28699
28848
|
var log9 = createLogger("zen-fs-config:config-repo");
|
|
28700
28849
|
var GROUP_DESCRIPTOR_FILE3 = `${META_DIR}/group.json`;
|
|
28701
28850
|
var GROUP_TYPE_FILE = `${CONFIG_DIR}/group-type`;
|
|
@@ -28735,7 +28884,7 @@ var ZenFSConfig = (() => {
|
|
|
28735
28884
|
}
|
|
28736
28885
|
return false;
|
|
28737
28886
|
}
|
|
28738
|
-
function
|
|
28887
|
+
function isNotFoundError2(err2) {
|
|
28739
28888
|
const code = err2?.code;
|
|
28740
28889
|
if (code === "ENOENT" || code === "ENOTDIR") return true;
|
|
28741
28890
|
const message = String(err2?.message ?? err2);
|
|
@@ -28875,6 +29024,8 @@ var ZenFSConfig = (() => {
|
|
|
28875
29024
|
__publicField(this, "instanceId");
|
|
28876
29025
|
/** 因归属他人而被跳过的后端 id → 原因,供 UI 展示。 */
|
|
28877
29026
|
__publicField(this, "skippedBackends", /* @__PURE__ */ new Map());
|
|
29027
|
+
/** 归属冲突的完整信息(两侧 kind / id / instanceId + 可执行动作)。 */
|
|
29028
|
+
__publicField(this, "backendConflicts", /* @__PURE__ */ new Map());
|
|
28878
29029
|
/** Last known backend descriptors, for the synchronous unified handle API. */
|
|
28879
29030
|
__publicField(this, "backendDescriptorCache", []);
|
|
28880
29031
|
/**
|
|
@@ -29293,7 +29444,7 @@ var ZenFSConfig = (() => {
|
|
|
29293
29444
|
await replica.instance.unlink(tombstone.path);
|
|
29294
29445
|
gone = true;
|
|
29295
29446
|
} catch (err2) {
|
|
29296
|
-
gone =
|
|
29447
|
+
gone = isNotFoundError2(err2);
|
|
29297
29448
|
}
|
|
29298
29449
|
if (gone) processed++;
|
|
29299
29450
|
}
|
|
@@ -30598,17 +30749,37 @@ var ZenFSConfig = (() => {
|
|
|
30598
30749
|
async bindBackendIdentity(instance, backendId) {
|
|
30599
30750
|
try {
|
|
30600
30751
|
const identity = await this.ensureGroupIdentity();
|
|
30601
|
-
const
|
|
30602
|
-
if (state === "conflict") {
|
|
30603
|
-
this.skippedBackends.set(
|
|
30752
|
+
const result = await bindRemoteGroupIdentityDetailed(instance, identity);
|
|
30753
|
+
if (result.state === "conflict") {
|
|
30754
|
+
this.skippedBackends.set(backendId, describeConflict(result));
|
|
30755
|
+
this.backendConflicts.set(backendId, {
|
|
30604
30756
|
backendId,
|
|
30605
|
-
|
|
30606
|
-
|
|
30757
|
+
reason: describeConflict(result),
|
|
30758
|
+
...result.conflict ? { conflict: result.conflict } : {},
|
|
30759
|
+
remote: result.remote,
|
|
30760
|
+
local: { kind: identity.kind, id: identity.id, instanceId: identity.instanceId },
|
|
30761
|
+
canAdoptRemoteInstance: !!result.remote?.instanceId && result.remote.kind === identity.kind && result.remote.id === identity.id,
|
|
30762
|
+
canRewriteRemoteIdentity: result.remote ? result.remote.kind === identity.kind : false,
|
|
30763
|
+
...result.unreadable ? { unreadable: true } : {},
|
|
30764
|
+
...result.error ? { error: result.error } : {}
|
|
30765
|
+
});
|
|
30766
|
+
} else {
|
|
30767
|
+
this.skippedBackends.delete(backendId);
|
|
30768
|
+
this.backendConflicts.delete(backendId);
|
|
30607
30769
|
}
|
|
30608
|
-
return state;
|
|
30770
|
+
return result.state;
|
|
30609
30771
|
} catch (err2) {
|
|
30610
30772
|
log9.warn(`[ConfigRepo] identity check failed for backend "${backendId}", skipping it:`, err2);
|
|
30611
|
-
|
|
30773
|
+
const message = err2?.message ?? String(err2);
|
|
30774
|
+
this.skippedBackends.set(backendId, `\u5F52\u5C5E\u6821\u9A8C\u5931\u8D25\uFF1A${message}`);
|
|
30775
|
+
this.backendConflicts.set(backendId, {
|
|
30776
|
+
backendId,
|
|
30777
|
+
reason: `\u5F52\u5C5E\u6821\u9A8C\u5931\u8D25\uFF1A${message}`,
|
|
30778
|
+
remote: null,
|
|
30779
|
+
local: { kind: "config", id: CONFIG_GROUP_ID, instanceId: this.instanceId },
|
|
30780
|
+
canAdoptRemoteInstance: false,
|
|
30781
|
+
canRewriteRemoteIdentity: false
|
|
30782
|
+
});
|
|
30612
30783
|
return "conflict";
|
|
30613
30784
|
}
|
|
30614
30785
|
}
|
|
@@ -30616,6 +30787,53 @@ var ZenFSConfig = (() => {
|
|
|
30616
30787
|
listSkippedBackends() {
|
|
30617
30788
|
return Array.from(this.skippedBackends, ([backendId, reason]) => ({ backendId, reason }));
|
|
30618
30789
|
}
|
|
30790
|
+
/** 归属冲突的完整信息(配置组也会被别的组占用同一个根)。 */
|
|
30791
|
+
listBackendConflicts() {
|
|
30792
|
+
return Array.from(this.backendConflicts.values());
|
|
30793
|
+
}
|
|
30794
|
+
/** 用户确认后解决配置组某个后端的归属冲突。 */
|
|
30795
|
+
async resolveBackendConflict(backendId, mode) {
|
|
30796
|
+
const identity = await this.ensureGroupIdentity();
|
|
30797
|
+
const desc = (this.backendDescriptorCache ?? []).find((b) => b.id === backendId);
|
|
30798
|
+
if (!desc) {
|
|
30799
|
+
return { mode, ok: false, reason: `\u627E\u4E0D\u5230\u540E\u7AEF ${backendId}\uFF08\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\uFF09` };
|
|
30800
|
+
}
|
|
30801
|
+
let instance;
|
|
30802
|
+
try {
|
|
30803
|
+
instance = await createBackend({ type: desc.type, options: desc.options });
|
|
30804
|
+
} catch (err2) {
|
|
30805
|
+
return { mode, ok: false, reason: `\u521B\u5EFA\u540E\u7AEF\u5931\u8D25\uFF1A${err2?.message ?? String(err2)}` };
|
|
30806
|
+
}
|
|
30807
|
+
try {
|
|
30808
|
+
const result = await resolveRemoteIdentity(instance, identity, mode);
|
|
30809
|
+
if (!result.ok) return { mode, ok: false, ...result.reason ? { reason: result.reason } : {} };
|
|
30810
|
+
if (mode === "adopt-remote-instance" && result.instanceId) {
|
|
30811
|
+
this.instanceId = result.instanceId;
|
|
30812
|
+
try {
|
|
30813
|
+
await writeGroupDescriptor(this.cachedFS, {
|
|
30814
|
+
schemaVersion: 2,
|
|
30815
|
+
kind: identity.kind,
|
|
30816
|
+
id: identity.id,
|
|
30817
|
+
instanceId: this.instanceId,
|
|
30818
|
+
...this.name ? { name: this.name } : {},
|
|
30819
|
+
features: CONFIG_GROUP_FEATURES
|
|
30820
|
+
});
|
|
30821
|
+
} catch (err2) {
|
|
30822
|
+
log9.warn("[ConfigRepo] failed to persist adopted instanceId:", err2);
|
|
30823
|
+
}
|
|
30824
|
+
}
|
|
30825
|
+
this.backendConflicts.delete(backendId);
|
|
30826
|
+
this.skippedBackends.delete(backendId);
|
|
30827
|
+
return { mode, ok: true, ...result.instanceId ? { instanceId: result.instanceId } : {} };
|
|
30828
|
+
} catch (err2) {
|
|
30829
|
+
return { mode, ok: false, reason: `\u5BF9\u9F50\u5931\u8D25\uFF1A${err2?.message ?? String(err2)}` };
|
|
30830
|
+
} finally {
|
|
30831
|
+
try {
|
|
30832
|
+
await instance.dispose?.();
|
|
30833
|
+
} catch {
|
|
30834
|
+
}
|
|
30835
|
+
}
|
|
30836
|
+
}
|
|
30619
30837
|
/** Write the group-type marker file if it doesn't exist. */
|
|
30620
30838
|
async ensureGroupType(type) {
|
|
30621
30839
|
this.assertNotDisposed();
|
|
@@ -30820,7 +31038,7 @@ var ZenFSConfig = (() => {
|
|
|
30820
31038
|
const features = meta?.features ?? existing?.features;
|
|
30821
31039
|
const liveGroup = this.appDataGroups.get(id);
|
|
30822
31040
|
const liveInstanceId = liveGroup?.getGroupInstanceId();
|
|
30823
|
-
const instanceId = pickInstanceId(existing) ?? (isValidGroupInstanceId(liveInstanceId) ? liveInstanceId : void 0);
|
|
31041
|
+
const instanceId = isValidGroupInstanceId(meta?.instanceId) ? meta.instanceId : pickInstanceId(existing) ?? (isValidGroupInstanceId(liveInstanceId) ? liveInstanceId : void 0);
|
|
30824
31042
|
const descriptor = {
|
|
30825
31043
|
id,
|
|
30826
31044
|
groupType: "data-sync",
|
|
@@ -31112,6 +31330,8 @@ var ZenFSConfig = (() => {
|
|
|
31112
31330
|
__publicField(this, "instanceId");
|
|
31113
31331
|
/** 因归属他人而被跳过的后端 id → 原因。 */
|
|
31114
31332
|
__publicField(this, "skippedBackends", /* @__PURE__ */ new Map());
|
|
31333
|
+
/** 归属冲突的完整信息(两侧 kind / id / instanceId + 可执行动作)。 */
|
|
31334
|
+
__publicField(this, "backendConflicts", /* @__PURE__ */ new Map());
|
|
31115
31335
|
__publicField(this, "_pollIntervalMs");
|
|
31116
31336
|
__publicField(this, "_backendsAreAuthoritative");
|
|
31117
31337
|
/** 引导副本(`.config/` 里的描述符)原有的能力位,用于回刷时不丢信息。 */
|
|
@@ -31259,32 +31479,126 @@ var ZenFSConfig = (() => {
|
|
|
31259
31479
|
async checkBackendOwnership(instance, backendId) {
|
|
31260
31480
|
if (!this.instanceId) {
|
|
31261
31481
|
this.skippedBackends.set(backendId, "\u672C\u7EC4\u5C1A\u672A\u5206\u914D instanceId\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF");
|
|
31482
|
+
this.backendConflicts.set(backendId, {
|
|
31483
|
+
backendId,
|
|
31484
|
+
reason: "\u672C\u7EC4\u5C1A\u672A\u5206\u914D instanceId\uFF0C\u5DF2\u8DF3\u8FC7\u8BE5\u540E\u7AEF",
|
|
31485
|
+
remote: null,
|
|
31486
|
+
local: { kind: "data", id: this.groupId, instanceId: void 0 },
|
|
31487
|
+
canAdoptRemoteInstance: false,
|
|
31488
|
+
canRewriteRemoteIdentity: false
|
|
31489
|
+
});
|
|
31262
31490
|
return "conflict";
|
|
31263
31491
|
}
|
|
31264
31492
|
try {
|
|
31265
|
-
const
|
|
31493
|
+
const identity = {
|
|
31266
31494
|
kind: "data",
|
|
31267
31495
|
id: this.groupId,
|
|
31268
31496
|
instanceId: this.instanceId,
|
|
31269
31497
|
...this.name ? { name: this.name } : {},
|
|
31270
31498
|
features: this.features
|
|
31271
|
-
}
|
|
31272
|
-
|
|
31273
|
-
|
|
31499
|
+
};
|
|
31500
|
+
const result = await bindRemoteGroupIdentityDetailed(instance, identity);
|
|
31501
|
+
if (result.state === "conflict") {
|
|
31502
|
+
this.skippedBackends.set(backendId, describeConflict(result));
|
|
31503
|
+
this.backendConflicts.set(backendId, {
|
|
31274
31504
|
backendId,
|
|
31275
|
-
|
|
31276
|
-
|
|
31505
|
+
reason: describeConflict(result),
|
|
31506
|
+
...result.conflict ? { conflict: result.conflict } : {},
|
|
31507
|
+
remote: result.remote,
|
|
31508
|
+
local: { kind: "data", id: this.groupId, instanceId: this.instanceId },
|
|
31509
|
+
// 只对齐 instanceId:要求 kind 与 id 都相同(同一个逻辑组,只有身份不同)。
|
|
31510
|
+
canAdoptRemoteInstance: !!result.remote?.instanceId && result.remote.kind === "data" && result.remote.id === this.groupId,
|
|
31511
|
+
// 改写远端:要求 kind 相同(组 id 不同才需要它,代价是动了共享的远端根)。
|
|
31512
|
+
canRewriteRemoteIdentity: result.remote ? result.remote.kind === "data" : false,
|
|
31513
|
+
...result.unreadable ? { unreadable: true } : {},
|
|
31514
|
+
...result.error ? { error: result.error } : {}
|
|
31515
|
+
});
|
|
31277
31516
|
log9.warn(
|
|
31278
31517
|
`[AppDataGroup:${this.groupId}] backend "${backendId}" belongs to another sync group \u2014 sync pair skipped`
|
|
31279
31518
|
);
|
|
31519
|
+
} else {
|
|
31520
|
+
this.skippedBackends.delete(backendId);
|
|
31521
|
+
this.backendConflicts.delete(backendId);
|
|
31280
31522
|
}
|
|
31281
|
-
return state;
|
|
31523
|
+
return result.state;
|
|
31282
31524
|
} catch (err2) {
|
|
31283
31525
|
log9.warn(`[AppDataGroup:${this.groupId}] ownership check failed for "${backendId}":`, err2);
|
|
31284
|
-
|
|
31526
|
+
const message = err2?.message ?? String(err2);
|
|
31527
|
+
this.skippedBackends.set(backendId, `\u5F52\u5C5E\u6821\u9A8C\u5931\u8D25\uFF1A${message}`);
|
|
31528
|
+
this.backendConflicts.set(backendId, {
|
|
31529
|
+
backendId,
|
|
31530
|
+
reason: `\u5F52\u5C5E\u6821\u9A8C\u5931\u8D25\uFF1A${message}`,
|
|
31531
|
+
remote: null,
|
|
31532
|
+
local: { kind: "data", id: this.groupId, instanceId: this.instanceId },
|
|
31533
|
+
canAdoptRemoteInstance: false,
|
|
31534
|
+
canRewriteRemoteIdentity: false
|
|
31535
|
+
});
|
|
31285
31536
|
return "conflict";
|
|
31286
31537
|
}
|
|
31287
31538
|
}
|
|
31539
|
+
/** 归属冲突的完整信息(UI 直接展示两侧身份,不用猜)。 */
|
|
31540
|
+
listBackendConflicts() {
|
|
31541
|
+
return Array.from(this.backendConflicts.values());
|
|
31542
|
+
}
|
|
31543
|
+
/**
|
|
31544
|
+
* 用户确认后解决归属冲突。
|
|
31545
|
+
*
|
|
31546
|
+
* - `adopt-remote-instance`:只把本地 instanceId 对齐成远端值(本地库名、
|
|
31547
|
+
* 引导副本路径都不变),随后重写 `.meta/group.json` 与引导副本。
|
|
31548
|
+
* - `rewrite-remote-identity`:把远端 `group.json` 改写成本组的 kind/id/
|
|
31549
|
+
* instanceId。会影响到共享该远端根的其它副本,调用方必须先警告用户。
|
|
31550
|
+
*
|
|
31551
|
+
* 成功后冲突记录被移除;调用方应重新连接(本组需要重新 init 才能建对)。
|
|
31552
|
+
*/
|
|
31553
|
+
async resolveBackendConflict(backendId, mode) {
|
|
31554
|
+
if (!this.instanceId) {
|
|
31555
|
+
return { mode, ok: false, reason: "\u672C\u7EC4\u5C1A\u672A\u5206\u914D instanceId\uFF0C\u65E0\u6CD5\u5BF9\u9F50" };
|
|
31556
|
+
}
|
|
31557
|
+
const desc = this._backends?.find((b) => b.id === backendId);
|
|
31558
|
+
if (!desc) {
|
|
31559
|
+
return { mode, ok: false, reason: `\u627E\u4E0D\u5230\u540E\u7AEF ${backendId}\uFF08\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\uFF09` };
|
|
31560
|
+
}
|
|
31561
|
+
let instance;
|
|
31562
|
+
try {
|
|
31563
|
+
instance = await createBackend({ type: desc.type, options: desc.options });
|
|
31564
|
+
} catch (err2) {
|
|
31565
|
+
return { mode, ok: false, reason: `\u521B\u5EFA\u540E\u7AEF\u5931\u8D25\uFF1A${err2?.message ?? String(err2)}` };
|
|
31566
|
+
}
|
|
31567
|
+
try {
|
|
31568
|
+
const identity = {
|
|
31569
|
+
kind: "data",
|
|
31570
|
+
id: this.groupId,
|
|
31571
|
+
instanceId: this.instanceId,
|
|
31572
|
+
...this.name ? { name: this.name } : {},
|
|
31573
|
+
features: this.features
|
|
31574
|
+
};
|
|
31575
|
+
const result = await resolveRemoteIdentity(instance, identity, mode);
|
|
31576
|
+
if (!result.ok) return { mode, ok: false, ...result.reason ? { reason: result.reason } : {} };
|
|
31577
|
+
if (mode === "adopt-remote-instance" && result.instanceId) {
|
|
31578
|
+
this.instanceId = result.instanceId;
|
|
31579
|
+
await this.writeOwnGroupDescriptor();
|
|
31580
|
+
try {
|
|
31581
|
+
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends ?? [], {
|
|
31582
|
+
name: this.name,
|
|
31583
|
+
features: this._declaredFeatures,
|
|
31584
|
+
instanceId: this.instanceId
|
|
31585
|
+
});
|
|
31586
|
+
} catch (err2) {
|
|
31587
|
+
log9.warn(`[AppDataGroup:${this.groupId}] failed to update bootstrap descriptor instanceId:`, err2);
|
|
31588
|
+
}
|
|
31589
|
+
}
|
|
31590
|
+
this.backendConflicts.delete(backendId);
|
|
31591
|
+
this.skippedBackends.delete(backendId);
|
|
31592
|
+
return { mode, ok: true, ...result.instanceId ? { instanceId: result.instanceId } : {} };
|
|
31593
|
+
} catch (err2) {
|
|
31594
|
+
return { mode, ok: false, reason: `\u5BF9\u9F50\u5931\u8D25\uFF1A${err2?.message ?? String(err2)}` };
|
|
31595
|
+
} finally {
|
|
31596
|
+
try {
|
|
31597
|
+
await instance.dispose?.();
|
|
31598
|
+
} catch {
|
|
31599
|
+
}
|
|
31600
|
+
}
|
|
31601
|
+
}
|
|
31288
31602
|
async init() {
|
|
31289
31603
|
const storeName = dataGroupLocalStoreName(this.appId, this.groupId);
|
|
31290
31604
|
try {
|
|
@@ -31961,14 +32275,142 @@ var ZenFSConfig = (() => {
|
|
|
31961
32275
|
return owner === "" ? null : owner;
|
|
31962
32276
|
}
|
|
31963
32277
|
|
|
32278
|
+
// src/local-purge.ts
|
|
32279
|
+
var CONFIG_STORE_PREFIX = "zen-fs-config-config-";
|
|
32280
|
+
var DATA_STORE_PREFIX = "zen-fs-config-data-";
|
|
32281
|
+
function getIdb() {
|
|
32282
|
+
const idb2 = globalThis.indexedDB;
|
|
32283
|
+
if (!idb2 || typeof idb2.deleteDatabase !== "function") return null;
|
|
32284
|
+
return idb2;
|
|
32285
|
+
}
|
|
32286
|
+
function deleteIndexedDbStore(name, timeoutMs = 4e3) {
|
|
32287
|
+
const idb2 = getIdb();
|
|
32288
|
+
if (!idb2) {
|
|
32289
|
+
return Promise.resolve({
|
|
32290
|
+
storeName: name,
|
|
32291
|
+
deleted: false,
|
|
32292
|
+
blocked: false,
|
|
32293
|
+
unsupported: true,
|
|
32294
|
+
error: "\u5F53\u524D\u73AF\u5883\u6CA1\u6709 IndexedDB\uFF1A\u65E0\u6CD5\u5220\u9664\u672C\u5730\u5E93"
|
|
32295
|
+
});
|
|
32296
|
+
}
|
|
32297
|
+
return new Promise((resolve4) => {
|
|
32298
|
+
let settled = false;
|
|
32299
|
+
let blocked = false;
|
|
32300
|
+
let timer;
|
|
32301
|
+
const finish = (result) => {
|
|
32302
|
+
if (settled) return;
|
|
32303
|
+
settled = true;
|
|
32304
|
+
if (timer) clearTimeout(timer);
|
|
32305
|
+
resolve4(result);
|
|
32306
|
+
};
|
|
32307
|
+
let request3;
|
|
32308
|
+
try {
|
|
32309
|
+
request3 = idb2.deleteDatabase(name);
|
|
32310
|
+
} catch (err2) {
|
|
32311
|
+
finish({ storeName: name, deleted: false, blocked: false, error: summarizeError(err2).message });
|
|
32312
|
+
return;
|
|
32313
|
+
}
|
|
32314
|
+
request3.onsuccess = () => finish({ storeName: name, deleted: true, blocked: false });
|
|
32315
|
+
request3.onerror = () => finish({
|
|
32316
|
+
storeName: name,
|
|
32317
|
+
deleted: false,
|
|
32318
|
+
blocked: false,
|
|
32319
|
+
error: summarizeError(request3.error).message
|
|
32320
|
+
});
|
|
32321
|
+
request3.onblocked = () => {
|
|
32322
|
+
blocked = true;
|
|
32323
|
+
};
|
|
32324
|
+
timer = setTimeout(() => {
|
|
32325
|
+
finish({
|
|
32326
|
+
storeName: name,
|
|
32327
|
+
deleted: false,
|
|
32328
|
+
blocked,
|
|
32329
|
+
error: blocked ? "\u5220\u9664\u88AB\u5176\u5B83\u9875\u9762/\u5B9E\u4F8B\u5360\u7528\uFF08blocked\uFF09\uFF1A\u8BF7\u5173\u95ED\u5176\u5B83\u6253\u5F00\u8BE5\u9875\u9762\u7684\u6807\u7B7E\u9875\u540E\u91CD\u8BD5" : "\u5220\u9664\u8D85\u65F6\uFF1AIndexedDB \u672A\u5728\u9884\u671F\u65F6\u95F4\u5185\u54CD\u5E94"
|
|
32330
|
+
});
|
|
32331
|
+
}, timeoutMs);
|
|
32332
|
+
});
|
|
32333
|
+
}
|
|
32334
|
+
function localSyncStoreNames(appId, groupIds = []) {
|
|
32335
|
+
const names = /* @__PURE__ */ new Set([
|
|
32336
|
+
`${CONFIG_STORE_PREFIX}${appId}`,
|
|
32337
|
+
`${DATA_STORE_PREFIX}${appId}`
|
|
32338
|
+
]);
|
|
32339
|
+
for (const groupId of groupIds) {
|
|
32340
|
+
if (!groupId) continue;
|
|
32341
|
+
names.add(`${DATA_STORE_PREFIX}${appId}-${groupId}`);
|
|
32342
|
+
}
|
|
32343
|
+
return Array.from(names);
|
|
32344
|
+
}
|
|
32345
|
+
async function purgeLocalSyncConfig(appId, options = {}) {
|
|
32346
|
+
const idb2 = getIdb();
|
|
32347
|
+
const names = new Set(localSyncStoreNames(appId, options.groupIds));
|
|
32348
|
+
const removedStorageKeys = [];
|
|
32349
|
+
const removeStorageKeys = () => {
|
|
32350
|
+
try {
|
|
32351
|
+
const ls = globalThis.localStorage;
|
|
32352
|
+
if (!ls) return;
|
|
32353
|
+
for (const key of options.extraStorageKeys ?? []) {
|
|
32354
|
+
try {
|
|
32355
|
+
if (ls.getItem(key) !== null) {
|
|
32356
|
+
ls.removeItem(key);
|
|
32357
|
+
removedStorageKeys.push(key);
|
|
32358
|
+
}
|
|
32359
|
+
} catch {
|
|
32360
|
+
}
|
|
32361
|
+
}
|
|
32362
|
+
} catch {
|
|
32363
|
+
}
|
|
32364
|
+
};
|
|
32365
|
+
if (!idb2) {
|
|
32366
|
+
removeStorageKeys();
|
|
32367
|
+
return { appId, databases: [], removedStorageKeys, unsupported: true };
|
|
32368
|
+
}
|
|
32369
|
+
try {
|
|
32370
|
+
const list2 = await idb2.databases?.();
|
|
32371
|
+
for (const entry of list2 ?? []) {
|
|
32372
|
+
const name = entry?.name;
|
|
32373
|
+
if (!name) continue;
|
|
32374
|
+
if (name === `${CONFIG_STORE_PREFIX}${appId}`) names.add(name);
|
|
32375
|
+
if (name === `${DATA_STORE_PREFIX}${appId}` || name.startsWith(`${DATA_STORE_PREFIX}${appId}-`)) {
|
|
32376
|
+
names.add(name);
|
|
32377
|
+
}
|
|
32378
|
+
}
|
|
32379
|
+
} catch {
|
|
32380
|
+
}
|
|
32381
|
+
const databases = [];
|
|
32382
|
+
for (const name of names) {
|
|
32383
|
+
databases.push(await deleteIndexedDbStore(name, options.timeoutMs));
|
|
32384
|
+
}
|
|
32385
|
+
removeStorageKeys();
|
|
32386
|
+
return { appId, databases, removedStorageKeys };
|
|
32387
|
+
}
|
|
32388
|
+
|
|
31964
32389
|
// src/connect.ts
|
|
31965
32390
|
init_backend_registry();
|
|
32391
|
+
var isInstanceIdLike = (value) => typeof value === "string" && isValidGroupInstanceId(value);
|
|
31966
32392
|
var log10 = createLogger3("connect");
|
|
31967
32393
|
var GROUP_TYPE_FILE2 = "/.config/group-type";
|
|
31968
32394
|
var LEGACY_GROUP_TYPE_FILE2 = "/.meta/group-type";
|
|
31969
|
-
async function
|
|
32395
|
+
async function detectGroupTypeDetailed(type, options) {
|
|
31970
32396
|
log10(`detectGroupType: connecting to ${type}...`);
|
|
31971
32397
|
const tempBackend = await createBackend({ type, options });
|
|
32398
|
+
let remote = null;
|
|
32399
|
+
try {
|
|
32400
|
+
try {
|
|
32401
|
+
const descriptor = await readGroupDescriptor(tempBackend);
|
|
32402
|
+
if (descriptor) {
|
|
32403
|
+
remote = {
|
|
32404
|
+
kind: descriptor.kind,
|
|
32405
|
+
id: descriptor.id,
|
|
32406
|
+
instanceId: isInstanceIdLike(descriptor.instanceId) ? descriptor.instanceId : void 0,
|
|
32407
|
+
...descriptor.name ? { name: descriptor.name } : {}
|
|
32408
|
+
};
|
|
32409
|
+
}
|
|
32410
|
+
} catch {
|
|
32411
|
+
}
|
|
32412
|
+
} finally {
|
|
32413
|
+
}
|
|
31972
32414
|
try {
|
|
31973
32415
|
for (const path of [GROUP_TYPE_FILE2, LEGACY_GROUP_TYPE_FILE2]) {
|
|
31974
32416
|
try {
|
|
@@ -31976,15 +32418,15 @@ var ZenFSConfig = (() => {
|
|
|
31976
32418
|
const groupType = raw.trim();
|
|
31977
32419
|
if (groupType === "config-sync" || groupType === "data-sync") {
|
|
31978
32420
|
log10(`detectGroupType: detected "${groupType}" at ${path}`);
|
|
31979
|
-
return groupType;
|
|
32421
|
+
return { groupType, remote };
|
|
31980
32422
|
}
|
|
31981
32423
|
log10(`detectGroupType: unknown group-type value "${groupType}" at ${path}, treating as null`);
|
|
31982
|
-
return null;
|
|
32424
|
+
return { groupType: null, remote };
|
|
31983
32425
|
} catch {
|
|
31984
32426
|
}
|
|
31985
32427
|
}
|
|
31986
32428
|
log10(`detectGroupType: no group-type file found (new backend)`);
|
|
31987
|
-
return null;
|
|
32429
|
+
return { groupType: null, remote };
|
|
31988
32430
|
} finally {
|
|
31989
32431
|
if (tempBackend?.dispose) {
|
|
31990
32432
|
await tempBackend.dispose();
|
|
@@ -32029,12 +32471,15 @@ var ZenFSConfig = (() => {
|
|
|
32029
32471
|
};
|
|
32030
32472
|
}
|
|
32031
32473
|
const { type, options: backendOptions } = options.backendInfo;
|
|
32032
|
-
const
|
|
32474
|
+
const detected = await detectGroupTypeDetailed(type, backendOptions);
|
|
32475
|
+
const detectedType = detected.groupType;
|
|
32033
32476
|
let groupType;
|
|
32034
32477
|
if (detectedType) {
|
|
32035
32478
|
if (options.groupType && options.groupType !== detectedType) {
|
|
32479
|
+
const remoteText = summarizeIdentity(detected.remote);
|
|
32480
|
+
const advice = detectedType === "config-sync" ? "\u8BE5\u8FDC\u7AEF\u6839\u5DF2\u88AB\u4E00\u4E2A\u914D\u7F6E\u7EC4\u5360\u7528\uFF1A\u8BF7\u7ED9\u6570\u636E\u7EC4\u6362\u4E00\u4E2A\u4E13\u5C5E\u7684\u8FDC\u7AEF\u6839\uFF0C\u6216\u5728\u914D\u7F6E\u7EC4\u4FA7\u89E3\u9664\u5BF9\u8BE5\u6839\u7684\u7ED1\u5B9A" : "\u8BE5\u8FDC\u7AEF\u6839\u5DF2\u88AB\u4E00\u4E2A\u6570\u636E\u7EC4\u5360\u7528\uFF1A\u8BF7\u7ED9\u914D\u7F6E\u7EC4\u6362\u4E00\u4E2A\u8FDC\u7AEF\u6839\uFF0C\u6216\u5220\u9664\u90A3\u4E2A\u6570\u636E\u7EC4\u540E\u7AEF";
|
|
32036
32481
|
throw new Error(
|
|
32037
|
-
`Group type mismatch:
|
|
32482
|
+
`Group type mismatch: \u8FDC\u7AEF\u6807\u8BB0\u4E3A "${detectedType}"\uFF08${remoteText}\uFF09\uFF0C\u672C\u7AEF\u8981\u6C42 "${options.groupType}"\u3002${advice}`
|
|
32038
32483
|
);
|
|
32039
32484
|
}
|
|
32040
32485
|
groupType = detectedType;
|