zen-fs-config 0.7.18 → 0.7.20
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.js +34 -11
- package/dist/index.mjs +34 -11
- package/dist/zen-fs-config.js +34 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5073,6 +5073,14 @@ var ConfigRepo = class {
|
|
|
5073
5073
|
log5.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
5074
5074
|
}
|
|
5075
5075
|
log5.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
5076
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
5077
|
+
try {
|
|
5078
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
5079
|
+
log5.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
5080
|
+
} catch (err) {
|
|
5081
|
+
log5.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err.message}`);
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5076
5084
|
}
|
|
5077
5085
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
5078
5086
|
async getGroupType() {
|
|
@@ -6538,9 +6546,19 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
6538
6546
|
}
|
|
6539
6547
|
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
6540
6548
|
if (declaredIdentity?.kind === "data") {
|
|
6541
|
-
|
|
6542
|
-
`[createConfigRepo]
|
|
6549
|
+
log5.warn(
|
|
6550
|
+
`[createConfigRepo] local primary carries a data-group descriptor (id=${declaredIdentity.id ?? "?"}) \u2014 rewriting it back to kind=config (its .meta/group.json was overwritten by sync)`
|
|
6543
6551
|
);
|
|
6552
|
+
await writeGroupDescriptor(primaryInstance, {
|
|
6553
|
+
schemaVersion: 2,
|
|
6554
|
+
kind: "config",
|
|
6555
|
+
id: CONFIG_GROUP_ID,
|
|
6556
|
+
// 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
|
|
6557
|
+
// 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
|
|
6558
|
+
instanceId: newGroupInstanceId(),
|
|
6559
|
+
...declaredIdentity.name ? { name: declaredIdentity.name } : {},
|
|
6560
|
+
features: CONFIG_GROUP_FEATURES
|
|
6561
|
+
});
|
|
6544
6562
|
}
|
|
6545
6563
|
try {
|
|
6546
6564
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
@@ -6561,6 +6579,11 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
6561
6579
|
features: CONFIG_GROUP_FEATURES
|
|
6562
6580
|
});
|
|
6563
6581
|
}
|
|
6582
|
+
try {
|
|
6583
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
6584
|
+
log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
6585
|
+
} catch {
|
|
6586
|
+
}
|
|
6564
6587
|
} catch (err) {
|
|
6565
6588
|
log5.warn(`[createConfigRepo] Failed to write group metadata:`, err.message);
|
|
6566
6589
|
}
|
|
@@ -6812,12 +6835,20 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6812
6835
|
} finally {
|
|
6813
6836
|
}
|
|
6814
6837
|
try {
|
|
6838
|
+
if (remote?.kind === "data") {
|
|
6839
|
+
log6("detectGroupType: .meta/group.json declares kind=data \u2192 data-sync");
|
|
6840
|
+
return { groupType: "data-sync", remote };
|
|
6841
|
+
}
|
|
6842
|
+
if (remote?.kind === "config") {
|
|
6843
|
+
log6("detectGroupType: .meta/group.json declares kind=config \u2192 config-sync");
|
|
6844
|
+
return { groupType: "config-sync", remote };
|
|
6845
|
+
}
|
|
6815
6846
|
for (const path of [GROUP_TYPE_FILE2, LEGACY_GROUP_TYPE_FILE2]) {
|
|
6816
6847
|
try {
|
|
6817
6848
|
const raw = await tempBackend.readFile(path, "utf-8");
|
|
6818
6849
|
const groupType = raw.trim();
|
|
6819
6850
|
if (groupType === "config-sync" || groupType === "data-sync") {
|
|
6820
|
-
log6(`detectGroupType: detected "${groupType}" at ${path}`);
|
|
6851
|
+
log6(`detectGroupType: detected "${groupType}" at ${path} (no descriptor)`);
|
|
6821
6852
|
return { groupType, remote };
|
|
6822
6853
|
}
|
|
6823
6854
|
log6(`detectGroupType: unknown group-type value "${groupType}" at ${path}, treating as null`);
|
|
@@ -6825,14 +6856,6 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6825
6856
|
} catch {
|
|
6826
6857
|
}
|
|
6827
6858
|
}
|
|
6828
|
-
if (remote?.kind === "data") {
|
|
6829
|
-
log6("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
6830
|
-
return { groupType: "data-sync", remote };
|
|
6831
|
-
}
|
|
6832
|
-
if (remote?.kind === "config") {
|
|
6833
|
-
log6("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
6834
|
-
return { groupType: "config-sync", remote };
|
|
6835
|
-
}
|
|
6836
6859
|
log6(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
6837
6860
|
return { groupType: null, remote };
|
|
6838
6861
|
} finally {
|
package/dist/index.mjs
CHANGED
|
@@ -4314,6 +4314,14 @@ var ConfigRepo = class {
|
|
|
4314
4314
|
log5.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
4315
4315
|
}
|
|
4316
4316
|
log5.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
4317
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
4318
|
+
try {
|
|
4319
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
4320
|
+
log5.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
4321
|
+
} catch (err) {
|
|
4322
|
+
log5.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err.message}`);
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4317
4325
|
}
|
|
4318
4326
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
4319
4327
|
async getGroupType() {
|
|
@@ -5779,9 +5787,19 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
5779
5787
|
}
|
|
5780
5788
|
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
5781
5789
|
if (declaredIdentity?.kind === "data") {
|
|
5782
|
-
|
|
5783
|
-
`[createConfigRepo]
|
|
5790
|
+
log5.warn(
|
|
5791
|
+
`[createConfigRepo] local primary carries a data-group descriptor (id=${declaredIdentity.id ?? "?"}) \u2014 rewriting it back to kind=config (its .meta/group.json was overwritten by sync)`
|
|
5784
5792
|
);
|
|
5793
|
+
await writeGroupDescriptor(primaryInstance, {
|
|
5794
|
+
schemaVersion: 2,
|
|
5795
|
+
kind: "config",
|
|
5796
|
+
id: CONFIG_GROUP_ID,
|
|
5797
|
+
// 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
|
|
5798
|
+
// 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
|
|
5799
|
+
instanceId: newGroupInstanceId(),
|
|
5800
|
+
...declaredIdentity.name ? { name: declaredIdentity.name } : {},
|
|
5801
|
+
features: CONFIG_GROUP_FEATURES
|
|
5802
|
+
});
|
|
5785
5803
|
}
|
|
5786
5804
|
try {
|
|
5787
5805
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
@@ -5802,6 +5820,11 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
5802
5820
|
features: CONFIG_GROUP_FEATURES
|
|
5803
5821
|
});
|
|
5804
5822
|
}
|
|
5823
|
+
try {
|
|
5824
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
5825
|
+
log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
5826
|
+
} catch {
|
|
5827
|
+
}
|
|
5805
5828
|
} catch (err) {
|
|
5806
5829
|
log5.warn(`[createConfigRepo] Failed to write group metadata:`, err.message);
|
|
5807
5830
|
}
|
|
@@ -6052,12 +6075,20 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6052
6075
|
} finally {
|
|
6053
6076
|
}
|
|
6054
6077
|
try {
|
|
6078
|
+
if (remote?.kind === "data") {
|
|
6079
|
+
log6("detectGroupType: .meta/group.json declares kind=data \u2192 data-sync");
|
|
6080
|
+
return { groupType: "data-sync", remote };
|
|
6081
|
+
}
|
|
6082
|
+
if (remote?.kind === "config") {
|
|
6083
|
+
log6("detectGroupType: .meta/group.json declares kind=config \u2192 config-sync");
|
|
6084
|
+
return { groupType: "config-sync", remote };
|
|
6085
|
+
}
|
|
6055
6086
|
for (const path of [GROUP_TYPE_FILE2, LEGACY_GROUP_TYPE_FILE2]) {
|
|
6056
6087
|
try {
|
|
6057
6088
|
const raw = await tempBackend.readFile(path, "utf-8");
|
|
6058
6089
|
const groupType = raw.trim();
|
|
6059
6090
|
if (groupType === "config-sync" || groupType === "data-sync") {
|
|
6060
|
-
log6(`detectGroupType: detected "${groupType}" at ${path}`);
|
|
6091
|
+
log6(`detectGroupType: detected "${groupType}" at ${path} (no descriptor)`);
|
|
6061
6092
|
return { groupType, remote };
|
|
6062
6093
|
}
|
|
6063
6094
|
log6(`detectGroupType: unknown group-type value "${groupType}" at ${path}, treating as null`);
|
|
@@ -6065,14 +6096,6 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6065
6096
|
} catch {
|
|
6066
6097
|
}
|
|
6067
6098
|
}
|
|
6068
|
-
if (remote?.kind === "data") {
|
|
6069
|
-
log6("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
6070
|
-
return { groupType: "data-sync", remote };
|
|
6071
|
-
}
|
|
6072
|
-
if (remote?.kind === "config") {
|
|
6073
|
-
log6("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
6074
|
-
return { groupType: "config-sync", remote };
|
|
6075
|
-
}
|
|
6076
6099
|
log6(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
6077
6100
|
return { groupType: null, remote };
|
|
6078
6101
|
} finally {
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -31030,6 +31030,14 @@ var ZenFSConfig = (() => {
|
|
|
31030
31030
|
log9.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
31031
31031
|
}
|
|
31032
31032
|
log9.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
31033
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
31034
|
+
try {
|
|
31035
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
31036
|
+
log9.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
31037
|
+
} catch (err2) {
|
|
31038
|
+
log9.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err2.message}`);
|
|
31039
|
+
}
|
|
31040
|
+
}
|
|
31033
31041
|
}
|
|
31034
31042
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
31035
31043
|
async getGroupType() {
|
|
@@ -32495,9 +32503,19 @@ var ZenFSConfig = (() => {
|
|
|
32495
32503
|
}
|
|
32496
32504
|
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
32497
32505
|
if (declaredIdentity?.kind === "data") {
|
|
32498
|
-
|
|
32499
|
-
`[createConfigRepo]
|
|
32506
|
+
log9.warn(
|
|
32507
|
+
`[createConfigRepo] local primary carries a data-group descriptor (id=${declaredIdentity.id ?? "?"}) \u2014 rewriting it back to kind=config (its .meta/group.json was overwritten by sync)`
|
|
32500
32508
|
);
|
|
32509
|
+
await writeGroupDescriptor(primaryInstance, {
|
|
32510
|
+
schemaVersion: 2,
|
|
32511
|
+
kind: "config",
|
|
32512
|
+
id: CONFIG_GROUP_ID,
|
|
32513
|
+
// 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
|
|
32514
|
+
// 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
|
|
32515
|
+
instanceId: newGroupInstanceId(),
|
|
32516
|
+
...declaredIdentity.name ? { name: declaredIdentity.name } : {},
|
|
32517
|
+
features: CONFIG_GROUP_FEATURES
|
|
32518
|
+
});
|
|
32501
32519
|
}
|
|
32502
32520
|
try {
|
|
32503
32521
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
@@ -32518,6 +32536,11 @@ var ZenFSConfig = (() => {
|
|
|
32518
32536
|
features: CONFIG_GROUP_FEATURES
|
|
32519
32537
|
});
|
|
32520
32538
|
}
|
|
32539
|
+
try {
|
|
32540
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
32541
|
+
log9.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
32542
|
+
} catch {
|
|
32543
|
+
}
|
|
32521
32544
|
} catch (err2) {
|
|
32522
32545
|
log9.warn(`[createConfigRepo] Failed to write group metadata:`, err2.message);
|
|
32523
32546
|
}
|
|
@@ -32769,12 +32792,20 @@ var ZenFSConfig = (() => {
|
|
|
32769
32792
|
} finally {
|
|
32770
32793
|
}
|
|
32771
32794
|
try {
|
|
32795
|
+
if (remote?.kind === "data") {
|
|
32796
|
+
log10("detectGroupType: .meta/group.json declares kind=data \u2192 data-sync");
|
|
32797
|
+
return { groupType: "data-sync", remote };
|
|
32798
|
+
}
|
|
32799
|
+
if (remote?.kind === "config") {
|
|
32800
|
+
log10("detectGroupType: .meta/group.json declares kind=config \u2192 config-sync");
|
|
32801
|
+
return { groupType: "config-sync", remote };
|
|
32802
|
+
}
|
|
32772
32803
|
for (const path of [GROUP_TYPE_FILE2, LEGACY_GROUP_TYPE_FILE2]) {
|
|
32773
32804
|
try {
|
|
32774
32805
|
const raw = await tempBackend.readFile(path, "utf-8");
|
|
32775
32806
|
const groupType = raw.trim();
|
|
32776
32807
|
if (groupType === "config-sync" || groupType === "data-sync") {
|
|
32777
|
-
log10(`detectGroupType: detected "${groupType}" at ${path}`);
|
|
32808
|
+
log10(`detectGroupType: detected "${groupType}" at ${path} (no descriptor)`);
|
|
32778
32809
|
return { groupType, remote };
|
|
32779
32810
|
}
|
|
32780
32811
|
log10(`detectGroupType: unknown group-type value "${groupType}" at ${path}, treating as null`);
|
|
@@ -32782,14 +32813,6 @@ var ZenFSConfig = (() => {
|
|
|
32782
32813
|
} catch {
|
|
32783
32814
|
}
|
|
32784
32815
|
}
|
|
32785
|
-
if (remote?.kind === "data") {
|
|
32786
|
-
log10("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
32787
|
-
return { groupType: "data-sync", remote };
|
|
32788
|
-
}
|
|
32789
|
-
if (remote?.kind === "config") {
|
|
32790
|
-
log10("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
32791
|
-
return { groupType: "config-sync", remote };
|
|
32792
|
-
}
|
|
32793
32816
|
log10(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
32794
32817
|
return { groupType: null, remote };
|
|
32795
32818
|
} finally {
|