zen-fs-config 0.6.4 → 0.7.0

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 CHANGED
@@ -432,7 +432,7 @@ interface SyncGroupHandle {
432
432
  /**
433
433
  * 该组**声明**的后端列表(权威定义,允许尚未连接成功的条目)。
434
434
  *
435
- * 数据组读自自己的 `.meta/backends/`;配置组读自 `.config/backends/`。
435
+ * 数据组与配置组都读自 `.meta/backends/`(唯一权威位置)。
436
436
  * 与 `listBackends()`(已连接视图)不同,这个列表不会因为后端暂时不可达
437
437
  * 而少显示条目。
438
438
  */
@@ -994,9 +994,9 @@ declare class ConfigRepo implements IConfigRepo {
994
994
  peekNodeConfig<T = unknown>(nodeId: string, path: string): Promise<T>;
995
995
  flush(): Promise<SyncResult[]>;
996
996
  /**
997
- * Write the tombstone record for `filePath` (new `.meta/tombstones` + legacy
998
- * mirror for one release cycle). Records only metadata — it never creates
999
- * the deleted file locally.
997
+ * Write the tombstone record for `filePath` under `.meta/tombstones/`.
998
+ * Records only metadata — it never creates the deleted file locally, and the
999
+ * legacy `/.meta/.deleted/` archive is neither read nor written.
1000
1000
  */
1001
1001
  private writeTombstoneFor;
1002
1002
  /**
@@ -1167,7 +1167,7 @@ declare class ConfigRepo implements IConfigRepo {
1167
1167
  private trackSyncErrors;
1168
1168
  /** Registered replica backend descriptors (excludes the implicit local primary). */
1169
1169
  listBackends(): AppDataBackendDescriptor[];
1170
- /** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
1170
+ /** 配置组的权威后端列表(`.meta/backends/`),与 `listBackends()` 相同。 */
1171
1171
  listDeclaredBackends(): AppDataBackendDescriptor[];
1172
1172
  /** Update the config-sync group's display name only. */
1173
1173
  rename(name: string): Promise<void>;
@@ -1191,15 +1191,22 @@ declare class ConfigRepo implements IConfigRepo {
1191
1191
  readMetaFile<T>(path: string): Promise<T | null>;
1192
1192
  /** Read a text file; `null` when absent (used for byte-compare-then-write). */
1193
1193
  private readTextIfExists;
1194
- /** Path for a single backend descriptor: .config/backends/{id}.json */
1194
+ /** Path for a single backend descriptor: `.meta/backends/{id}.json`. */
1195
1195
  backendFilePath(id: string): string;
1196
- /** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
1196
+ /**
1197
+ * Legacy pre-0.7 path `/.config/backends/{id}.json`.
1198
+ *
1199
+ * 该目录已不再读取:此处只用于删除后端时尽力清理残留副本。
1200
+ */
1197
1201
  legacyBackendFilePath(id: string): string;
1198
1202
  /** Read every parseable descriptor in one directory. */
1199
1203
  private readBackendDescriptorsFrom;
1200
1204
  /**
1201
- * Read all backend descriptors from `.config/backends/*.json` with legacy
1202
- * `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
1205
+ * Read all backend descriptors from `.meta/backends/*.json` — the single
1206
+ * authoritative location for both config-sync and data-sync groups.
1207
+ *
1208
+ * `/.config/backends/` is intentionally **not** read: leftovers there are
1209
+ * plain content and never take part in backend enumeration.
1203
1210
  *
1204
1211
  * If duplicate backends are detected (same type + options but different id),
1205
1212
  * only the first one (sorted by id) is kept and the rest are removed
@@ -1207,15 +1214,16 @@ declare class ConfigRepo implements IConfigRepo {
1207
1214
  */
1208
1215
  readAllBackendDescriptors(): Promise<BackendDescriptor[]>;
1209
1216
  /**
1210
- * Write a single backend descriptor to `.config/backends/{id}.json`,
1211
- * mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
1212
- * so older clients still see the backend.
1217
+ * Write a single backend descriptor to `.meta/backends/{id}.json`.
1213
1218
  *
1214
- * Both files use the canonical serializer and are only written when their
1215
- * bytes actually differ (no needless sync churn).
1219
+ * Uses the canonical serializer and is only written when the bytes actually
1220
+ * differ (no needless sync churn). `/.config/backends/` is never written.
1216
1221
  */
1217
1222
  writeBackendDescriptor(desc: BackendDescriptor): Promise<void>;
1218
- /** Remove a single backend descriptor file + its version sidecar (both layouts) */
1223
+ /**
1224
+ * Remove a single backend descriptor: always `.meta/backends/{id}.json`, plus
1225
+ * a best-effort cleanup of the legacy `/.config/backends/{id}.json` residue.
1226
+ */
1219
1227
  removeBackendDescriptor(id: string): Promise<void>;
1220
1228
  getBackends(): Promise<BackendsMeta | null>;
1221
1229
  updateBackends(meta: BackendsMeta): Promise<void>;
@@ -1247,8 +1255,9 @@ declare class ConfigRepo implements IConfigRepo {
1247
1255
  /** Legacy descriptor path: .meta/app-data-groups/{appId}/{id}.json */
1248
1256
  private legacyAppDataGroupFilePath;
1249
1257
  /**
1250
- * Write a data-group descriptor to `.config/` (bootstrap copy), mirroring to
1251
- * the legacy `.meta/` path.
1258
+ * Write a data-group descriptor to `.config/app-data-groups/` (registration
1259
+ * + bootstrap copy). The legacy `.meta/app-data-groups/` mirror is no longer
1260
+ * written; it is still read so old layouts keep working.
1252
1261
  *
1253
1262
  * 这份描述符是**引导副本**:它让只有配置组凭据的新设备知道有哪些数据组、
1254
1263
  * 远端在哪。权威定义在数据组自己的 `.meta/backends/`。
@@ -1477,7 +1486,7 @@ declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, a
1477
1486
  * Implements the layout agreed in SYNC-GROUP-UNIFICATION.zh-CN.md:
1478
1487
  *
1479
1488
  * /.meta/group.json # group descriptor (kind/id/features)
1480
- * /.meta/tombstones/{encoded}.json # tombstones (legacy: /.meta/.deleted)
1489
+ * /.meta/tombstones/{encoded}.json # tombstones (the only deletion record)
1481
1490
  * /.meta/versions/{encoded}.json # version records for data groups
1482
1491
  * /.meta/conflicts/{conflictId}/ # conflict archives (legacy: /.meta/.conflicts)
1483
1492
  * /.config/** # config-sync only (not synced by data groups)
@@ -1490,6 +1499,10 @@ declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, a
1490
1499
  declare const META_DIR = "/.meta";
1491
1500
  declare const GROUP_DESCRIPTOR_FILE = "/.meta/group.json";
1492
1501
  declare const TOMBSTONES_DIR = "/.meta/tombstones";
1502
+ /**
1503
+ * 历史归档目录。仅作为常量保留(旧数据仍在远端,按普通内容对待):
1504
+ * 既不读取也不写入,删除状态只以 {@link TOMBSTONES_DIR} 为准。
1505
+ */
1493
1506
  declare const LEGACY_TOMBSTONES_DIR = "/.meta/.deleted";
1494
1507
  declare const VERSIONS_DIR = "/.meta/versions";
1495
1508
  declare const CONFLICTS_DIR = "/.meta/conflicts";
@@ -1527,22 +1540,20 @@ interface TombstoneTarget {
1527
1540
  /**
1528
1541
  * Tombstone store for a group's local store.
1529
1542
  *
1530
- * New writes go to `/.meta/tombstones/`; for one release cycle a mirror copy is
1531
- * also written to the legacy `/.meta/.deleted/` path so older clients still see
1532
- * deletions. Reads accept both.
1543
+ * 删除状态只写在 `/.meta/tombstones/`;历史归档目录不再读写。
1533
1544
  */
1534
1545
  declare class TombstoneStore {
1535
1546
  private fs;
1536
1547
  private author;
1537
1548
  constructor(fs: MetaFS, author: string);
1538
1549
  private pathFor;
1539
- /** All tombstones, new path first, legacy only for paths not already seen. */
1550
+ /** All tombstones. */
1540
1551
  list(): Promise<TombstoneMeta[]>;
1541
- /** Write a tombstone (new + legacy mirror). */
1552
+ /** Write a tombstone. */
1542
1553
  write(tombstone: TombstoneMeta): Promise<void>;
1543
- /** Persist an updated tombstone (confirmations) to whichever paths exist. */
1554
+ /** Persist an updated tombstone (confirmations) when it still exists. */
1544
1555
  save(tombstone: TombstoneMeta): Promise<void>;
1545
- /** Delete a tombstone from both layouts. */
1556
+ /** Delete a tombstone. */
1546
1557
  remove(tombstone: TombstoneMeta): Promise<void>;
1547
1558
  /**
1548
1559
  * Delete every tombstoned file (and its version record) on the local store
@@ -1552,7 +1563,7 @@ declare class TombstoneStore {
1552
1563
  private deleteEverywhere;
1553
1564
  /** Add the given backend ids to every tombstone's confirmation set. */
1554
1565
  confirm(backendIds: string[]): Promise<number>;
1555
- /** Remove tombstones confirmed by every connected backend (and their mirrors). */
1566
+ /** Remove tombstones confirmed by every connected backend. */
1556
1567
  gc(allBackendIds: string[], targets?: TombstoneTarget[]): Promise<void>;
1557
1568
  }
1558
1569
  /**
package/dist/index.d.ts CHANGED
@@ -432,7 +432,7 @@ interface SyncGroupHandle {
432
432
  /**
433
433
  * 该组**声明**的后端列表(权威定义,允许尚未连接成功的条目)。
434
434
  *
435
- * 数据组读自自己的 `.meta/backends/`;配置组读自 `.config/backends/`。
435
+ * 数据组与配置组都读自 `.meta/backends/`(唯一权威位置)。
436
436
  * 与 `listBackends()`(已连接视图)不同,这个列表不会因为后端暂时不可达
437
437
  * 而少显示条目。
438
438
  */
@@ -994,9 +994,9 @@ declare class ConfigRepo implements IConfigRepo {
994
994
  peekNodeConfig<T = unknown>(nodeId: string, path: string): Promise<T>;
995
995
  flush(): Promise<SyncResult[]>;
996
996
  /**
997
- * Write the tombstone record for `filePath` (new `.meta/tombstones` + legacy
998
- * mirror for one release cycle). Records only metadata — it never creates
999
- * the deleted file locally.
997
+ * Write the tombstone record for `filePath` under `.meta/tombstones/`.
998
+ * Records only metadata — it never creates the deleted file locally, and the
999
+ * legacy `/.meta/.deleted/` archive is neither read nor written.
1000
1000
  */
1001
1001
  private writeTombstoneFor;
1002
1002
  /**
@@ -1167,7 +1167,7 @@ declare class ConfigRepo implements IConfigRepo {
1167
1167
  private trackSyncErrors;
1168
1168
  /** Registered replica backend descriptors (excludes the implicit local primary). */
1169
1169
  listBackends(): AppDataBackendDescriptor[];
1170
- /** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
1170
+ /** 配置组的权威后端列表(`.meta/backends/`),与 `listBackends()` 相同。 */
1171
1171
  listDeclaredBackends(): AppDataBackendDescriptor[];
1172
1172
  /** Update the config-sync group's display name only. */
1173
1173
  rename(name: string): Promise<void>;
@@ -1191,15 +1191,22 @@ declare class ConfigRepo implements IConfigRepo {
1191
1191
  readMetaFile<T>(path: string): Promise<T | null>;
1192
1192
  /** Read a text file; `null` when absent (used for byte-compare-then-write). */
1193
1193
  private readTextIfExists;
1194
- /** Path for a single backend descriptor: .config/backends/{id}.json */
1194
+ /** Path for a single backend descriptor: `.meta/backends/{id}.json`. */
1195
1195
  backendFilePath(id: string): string;
1196
- /** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
1196
+ /**
1197
+ * Legacy pre-0.7 path `/.config/backends/{id}.json`.
1198
+ *
1199
+ * 该目录已不再读取:此处只用于删除后端时尽力清理残留副本。
1200
+ */
1197
1201
  legacyBackendFilePath(id: string): string;
1198
1202
  /** Read every parseable descriptor in one directory. */
1199
1203
  private readBackendDescriptorsFrom;
1200
1204
  /**
1201
- * Read all backend descriptors from `.config/backends/*.json` with legacy
1202
- * `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
1205
+ * Read all backend descriptors from `.meta/backends/*.json` — the single
1206
+ * authoritative location for both config-sync and data-sync groups.
1207
+ *
1208
+ * `/.config/backends/` is intentionally **not** read: leftovers there are
1209
+ * plain content and never take part in backend enumeration.
1203
1210
  *
1204
1211
  * If duplicate backends are detected (same type + options but different id),
1205
1212
  * only the first one (sorted by id) is kept and the rest are removed
@@ -1207,15 +1214,16 @@ declare class ConfigRepo implements IConfigRepo {
1207
1214
  */
1208
1215
  readAllBackendDescriptors(): Promise<BackendDescriptor[]>;
1209
1216
  /**
1210
- * Write a single backend descriptor to `.config/backends/{id}.json`,
1211
- * mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
1212
- * so older clients still see the backend.
1217
+ * Write a single backend descriptor to `.meta/backends/{id}.json`.
1213
1218
  *
1214
- * Both files use the canonical serializer and are only written when their
1215
- * bytes actually differ (no needless sync churn).
1219
+ * Uses the canonical serializer and is only written when the bytes actually
1220
+ * differ (no needless sync churn). `/.config/backends/` is never written.
1216
1221
  */
1217
1222
  writeBackendDescriptor(desc: BackendDescriptor): Promise<void>;
1218
- /** Remove a single backend descriptor file + its version sidecar (both layouts) */
1223
+ /**
1224
+ * Remove a single backend descriptor: always `.meta/backends/{id}.json`, plus
1225
+ * a best-effort cleanup of the legacy `/.config/backends/{id}.json` residue.
1226
+ */
1219
1227
  removeBackendDescriptor(id: string): Promise<void>;
1220
1228
  getBackends(): Promise<BackendsMeta | null>;
1221
1229
  updateBackends(meta: BackendsMeta): Promise<void>;
@@ -1247,8 +1255,9 @@ declare class ConfigRepo implements IConfigRepo {
1247
1255
  /** Legacy descriptor path: .meta/app-data-groups/{appId}/{id}.json */
1248
1256
  private legacyAppDataGroupFilePath;
1249
1257
  /**
1250
- * Write a data-group descriptor to `.config/` (bootstrap copy), mirroring to
1251
- * the legacy `.meta/` path.
1258
+ * Write a data-group descriptor to `.config/app-data-groups/` (registration
1259
+ * + bootstrap copy). The legacy `.meta/app-data-groups/` mirror is no longer
1260
+ * written; it is still read so old layouts keep working.
1252
1261
  *
1253
1262
  * 这份描述符是**引导副本**:它让只有配置组凭据的新设备知道有哪些数据组、
1254
1263
  * 远端在哪。权威定义在数据组自己的 `.meta/backends/`。
@@ -1477,7 +1486,7 @@ declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, a
1477
1486
  * Implements the layout agreed in SYNC-GROUP-UNIFICATION.zh-CN.md:
1478
1487
  *
1479
1488
  * /.meta/group.json # group descriptor (kind/id/features)
1480
- * /.meta/tombstones/{encoded}.json # tombstones (legacy: /.meta/.deleted)
1489
+ * /.meta/tombstones/{encoded}.json # tombstones (the only deletion record)
1481
1490
  * /.meta/versions/{encoded}.json # version records for data groups
1482
1491
  * /.meta/conflicts/{conflictId}/ # conflict archives (legacy: /.meta/.conflicts)
1483
1492
  * /.config/** # config-sync only (not synced by data groups)
@@ -1490,6 +1499,10 @@ declare function verifyOrRepairVersion(fs: SyncableFS, configFilePath: string, a
1490
1499
  declare const META_DIR = "/.meta";
1491
1500
  declare const GROUP_DESCRIPTOR_FILE = "/.meta/group.json";
1492
1501
  declare const TOMBSTONES_DIR = "/.meta/tombstones";
1502
+ /**
1503
+ * 历史归档目录。仅作为常量保留(旧数据仍在远端,按普通内容对待):
1504
+ * 既不读取也不写入,删除状态只以 {@link TOMBSTONES_DIR} 为准。
1505
+ */
1493
1506
  declare const LEGACY_TOMBSTONES_DIR = "/.meta/.deleted";
1494
1507
  declare const VERSIONS_DIR = "/.meta/versions";
1495
1508
  declare const CONFLICTS_DIR = "/.meta/conflicts";
@@ -1527,22 +1540,20 @@ interface TombstoneTarget {
1527
1540
  /**
1528
1541
  * Tombstone store for a group's local store.
1529
1542
  *
1530
- * New writes go to `/.meta/tombstones/`; for one release cycle a mirror copy is
1531
- * also written to the legacy `/.meta/.deleted/` path so older clients still see
1532
- * deletions. Reads accept both.
1543
+ * 删除状态只写在 `/.meta/tombstones/`;历史归档目录不再读写。
1533
1544
  */
1534
1545
  declare class TombstoneStore {
1535
1546
  private fs;
1536
1547
  private author;
1537
1548
  constructor(fs: MetaFS, author: string);
1538
1549
  private pathFor;
1539
- /** All tombstones, new path first, legacy only for paths not already seen. */
1550
+ /** All tombstones. */
1540
1551
  list(): Promise<TombstoneMeta[]>;
1541
- /** Write a tombstone (new + legacy mirror). */
1552
+ /** Write a tombstone. */
1542
1553
  write(tombstone: TombstoneMeta): Promise<void>;
1543
- /** Persist an updated tombstone (confirmations) to whichever paths exist. */
1554
+ /** Persist an updated tombstone (confirmations) when it still exists. */
1544
1555
  save(tombstone: TombstoneMeta): Promise<void>;
1545
- /** Delete a tombstone from both layouts. */
1556
+ /** Delete a tombstone. */
1546
1557
  remove(tombstone: TombstoneMeta): Promise<void>;
1547
1558
  /**
1548
1559
  * Delete every tombstoned file (and its version record) on the local store
@@ -1552,7 +1563,7 @@ declare class TombstoneStore {
1552
1563
  private deleteEverywhere;
1553
1564
  /** Add the given backend ids to every tombstone's confirmation set. */
1554
1565
  confirm(backendIds: string[]): Promise<number>;
1555
- /** Remove tombstones confirmed by every connected backend (and their mirrors). */
1566
+ /** Remove tombstones confirmed by every connected backend. */
1556
1567
  gc(allBackendIds: string[], targets?: TombstoneTarget[]): Promise<void>;
1557
1568
  }
1558
1569
  /**
package/dist/index.js CHANGED
@@ -1717,12 +1717,13 @@ function mergeTombstone(byPath, tombstone) {
1717
1717
  }
1718
1718
  async function readTombstonesFromFs(fs, warn) {
1719
1719
  const byPath = /* @__PURE__ */ new Map();
1720
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1720
+ {
1721
+ const dir = TOMBSTONES_DIR;
1721
1722
  let entries;
1722
1723
  try {
1723
1724
  entries = await fs.readdir(dir);
1724
1725
  } catch {
1725
- continue;
1726
+ return [];
1726
1727
  }
1727
1728
  for (const entry of entries) {
1728
1729
  if (!entry.endsWith(".json")) continue;
@@ -1818,43 +1819,34 @@ var TombstoneStore = class {
1818
1819
  }
1819
1820
  fs;
1820
1821
  author;
1821
- pathFor(filePath, dir = TOMBSTONES_DIR) {
1822
- return `${dir}/${encodeMetaPath(filePath)}.json`;
1822
+ pathFor(filePath) {
1823
+ return `${TOMBSTONES_DIR}/${encodeMetaPath(filePath)}.json`;
1823
1824
  }
1824
- /** All tombstones, new path first, legacy only for paths not already seen. */
1825
+ /** All tombstones. */
1825
1826
  async list() {
1826
1827
  return readTombstonesFromFs(this.fs, (message) => log2.warn(message));
1827
1828
  }
1828
- /** Write a tombstone (new + legacy mirror). */
1829
+ /** Write a tombstone. */
1829
1830
  async write(tombstone) {
1830
1831
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
1831
- const paths = [
1832
- this.pathFor(tombstone.path),
1833
- this.pathFor(tombstone.path, LEGACY_TOMBSTONES_DIR)
1834
- ];
1835
- for (const p of paths) {
1836
- await ensureParentDir2(this.fs, p);
1837
- await this.fs.writeFile(p, bytes);
1838
- }
1832
+ const p = this.pathFor(tombstone.path);
1833
+ await ensureParentDir2(this.fs, p);
1834
+ await this.fs.writeFile(p, bytes);
1839
1835
  }
1840
- /** Persist an updated tombstone (confirmations) to whichever paths exist. */
1836
+ /** Persist an updated tombstone (confirmations) when it still exists. */
1841
1837
  async save(tombstone) {
1842
1838
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
1843
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1844
- const p = this.pathFor(tombstone.path, dir);
1845
- if (!await existsSafe(this.fs, p)) continue;
1846
- await this.fs.writeFile(p, bytes);
1847
- }
1839
+ const p = this.pathFor(tombstone.path);
1840
+ if (!await existsSafe(this.fs, p)) return;
1841
+ await this.fs.writeFile(p, bytes);
1848
1842
  }
1849
- /** Delete a tombstone from both layouts. */
1843
+ /** Delete a tombstone. */
1850
1844
  async remove(tombstone) {
1851
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1852
- const p = this.pathFor(tombstone.path, dir);
1853
- if (!await existsSafe(this.fs, p)) continue;
1854
- try {
1855
- await this.fs.unlink(p);
1856
- } catch {
1857
- }
1845
+ const p = this.pathFor(tombstone.path);
1846
+ if (!await existsSafe(this.fs, p)) return;
1847
+ try {
1848
+ await this.fs.unlink(p);
1849
+ } catch {
1858
1850
  }
1859
1851
  }
1860
1852
  /**
@@ -1898,28 +1890,26 @@ var TombstoneStore = class {
1898
1890
  }
1899
1891
  return modified;
1900
1892
  }
1901
- /** Remove tombstones confirmed by every connected backend (and their mirrors). */
1893
+ /** Remove tombstones confirmed by every connected backend. */
1902
1894
  async gc(allBackendIds, targets = []) {
1903
1895
  const tombstones = await this.list();
1904
1896
  for (const tombstone of tombstones) {
1905
1897
  const allConfirmed = allBackendIds.every((id) => tombstone.confirmedBy.includes(id));
1906
1898
  if (!allConfirmed) continue;
1907
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1908
- const p = this.pathFor(tombstone.path, dir);
1909
- if (await existsSafe(this.fs, p)) {
1899
+ const p = this.pathFor(tombstone.path);
1900
+ if (await existsSafe(this.fs, p)) {
1901
+ try {
1902
+ await this.fs.unlink(p);
1903
+ } catch {
1904
+ }
1905
+ }
1906
+ for (const target of targets) {
1907
+ if (await existsSafe(target.fs, p)) {
1910
1908
  try {
1911
- await this.fs.unlink(p);
1909
+ await target.fs.unlink(p);
1912
1910
  } catch {
1913
1911
  }
1914
1912
  }
1915
- for (const target of targets) {
1916
- if (await existsSafe(target.fs, p)) {
1917
- try {
1918
- await target.fs.unlink(p);
1919
- } catch {
1920
- }
1921
- }
1922
- }
1923
1913
  }
1924
1914
  }
1925
1915
  }
@@ -2060,8 +2050,8 @@ var GROUP_DESCRIPTOR_FILE2 = `${META_DIR}/group.json`;
2060
2050
  var GROUP_TYPE_FILE = `${CONFIG_DIR}/group-type`;
2061
2051
  var LEGACY_GROUP_TYPE_FILE = `${META_DIR}/group-type`;
2062
2052
  var BACKENDS_FILE = `${META_DIR}/backends.json`;
2063
- var BACKENDS_DIR = `${CONFIG_DIR}/backends`;
2064
- var LEGACY_BACKENDS_DIR = META_BACKENDS_DIR;
2053
+ var BACKENDS_DIR = META_BACKENDS_DIR;
2054
+ var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
2065
2055
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
2066
2056
  var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
2067
2057
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
@@ -2447,9 +2437,9 @@ var ConfigRepo = class {
2447
2437
  // Tombstone (Deletion Tracking)
2448
2438
  // -----------------------------------------------------------------------
2449
2439
  /**
2450
- * Write the tombstone record for `filePath` (new `.meta/tombstones` + legacy
2451
- * mirror for one release cycle). Records only metadata — it never creates
2452
- * the deleted file locally.
2440
+ * Write the tombstone record for `filePath` under `.meta/tombstones/`.
2441
+ * Records only metadata — it never creates the deleted file locally, and the
2442
+ * legacy `/.meta/.deleted/` archive is neither read nor written.
2453
2443
  */
2454
2444
  async writeTombstoneFor(filePath) {
2455
2445
  const normalizedPath = filePath.startsWith("/") ? filePath : "/" + filePath;
@@ -2460,11 +2450,9 @@ var ConfigRepo = class {
2460
2450
  confirmedBy: [this.primaryBackendId]
2461
2451
  };
2462
2452
  const tombstoneBytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
2463
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
2464
- const tombstonePath = tombstonePathFor(normalizedPath, dir);
2465
- await this.ensureDir(tombstonePath);
2466
- await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
2467
- }
2453
+ const tombstonePath = tombstonePathFor(normalizedPath, TOMBSTONES_DIR);
2454
+ await this.ensureDir(tombstonePath);
2455
+ await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
2468
2456
  }
2469
2457
  /**
2470
2458
  * Delete a file and write a tombstone so the deletion propagates
@@ -2909,11 +2897,9 @@ var ConfigRepo = class {
2909
2897
  if (changed) {
2910
2898
  try {
2911
2899
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
2912
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
2913
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
2914
- if (await this.safeExists(this.cachedFS, tombstonePath)) {
2915
- await this.cachedFS.writeFile(tombstonePath, bytes);
2916
- }
2900
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
2901
+ if (await this.safeExists(this.cachedFS, tombstonePath)) {
2902
+ await this.cachedFS.writeFile(tombstonePath, bytes);
2917
2903
  }
2918
2904
  modified++;
2919
2905
  } catch {
@@ -2961,22 +2947,20 @@ var ConfigRepo = class {
2961
2947
  for (const tombstone of tombstones) {
2962
2948
  const allConfirmed = await this.allReplicasConfirmAbsent(tombstone.path);
2963
2949
  if (allConfirmed) {
2964
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
2965
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
2966
- try {
2967
- await this.cachedFS.unlink(tombstonePath);
2968
- } catch {
2969
- }
2970
- for (const [, replica] of this.replicaBackends) {
2971
- if (await this.safeExists(replica.instance, tombstonePath)) {
2972
- try {
2973
- await replica.instance.unlink(tombstonePath);
2974
- } catch {
2975
- }
2950
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
2951
+ try {
2952
+ await this.cachedFS.unlink(tombstonePath);
2953
+ } catch {
2954
+ }
2955
+ for (const [, replica] of this.replicaBackends) {
2956
+ if (await this.safeExists(replica.instance, tombstonePath)) {
2957
+ try {
2958
+ await replica.instance.unlink(tombstonePath);
2959
+ } catch {
2976
2960
  }
2977
2961
  }
2978
- log3.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
2979
2962
  }
2963
+ log3.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
2980
2964
  }
2981
2965
  }
2982
2966
  }
@@ -3040,7 +3024,7 @@ var ConfigRepo = class {
3040
3024
  this.assertNotDisposed();
3041
3025
  return [...this.backendDescriptorCache];
3042
3026
  }
3043
- /** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
3027
+ /** 配置组的权威后端列表(`.meta/backends/`),与 `listBackends()` 相同。 */
3044
3028
  listDeclaredBackends() {
3045
3029
  return this.listBackends();
3046
3030
  }
@@ -3433,11 +3417,15 @@ var ConfigRepo = class {
3433
3417
  // -----------------------------------------------------------------------
3434
3418
  // Internal — Individual Backend Descriptor Files
3435
3419
  // -----------------------------------------------------------------------
3436
- /** Path for a single backend descriptor: .config/backends/{id}.json */
3420
+ /** Path for a single backend descriptor: `.meta/backends/{id}.json`. */
3437
3421
  backendFilePath(id) {
3438
3422
  return `${BACKENDS_DIR}/${id}.json`;
3439
3423
  }
3440
- /** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
3424
+ /**
3425
+ * Legacy pre-0.7 path `/.config/backends/{id}.json`.
3426
+ *
3427
+ * 该目录已不再读取:此处只用于删除后端时尽力清理残留副本。
3428
+ */
3441
3429
  legacyBackendFilePath(id) {
3442
3430
  return `${LEGACY_BACKENDS_DIR}/${id}.json`;
3443
3431
  }
@@ -3486,8 +3474,11 @@ var ConfigRepo = class {
3486
3474
  return { items, corruptFiles };
3487
3475
  }
3488
3476
  /**
3489
- * Read all backend descriptors from `.config/backends/*.json` with legacy
3490
- * `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
3477
+ * Read all backend descriptors from `.meta/backends/*.json` — the single
3478
+ * authoritative location for both config-sync and data-sync groups.
3479
+ *
3480
+ * `/.config/backends/` is intentionally **not** read: leftovers there are
3481
+ * plain content and never take part in backend enumeration.
3491
3482
  *
3492
3483
  * If duplicate backends are detected (same type + options but different id),
3493
3484
  * only the first one (sorted by id) is kept and the rest are removed
@@ -3495,16 +3486,8 @@ var ConfigRepo = class {
3495
3486
  */
3496
3487
  async readAllBackendDescriptors() {
3497
3488
  const fresh = await this.readBackendDescriptorsFrom(BACKENDS_DIR);
3498
- const legacy = await this.readBackendDescriptorsFrom(LEGACY_BACKENDS_DIR);
3499
3489
  const items = [...fresh.items];
3500
- const seenIds = new Set(items.map((i) => i.desc.id));
3501
- for (const item of legacy.items) {
3502
- if (!seenIds.has(item.desc.id)) {
3503
- items.push(item);
3504
- seenIds.add(item.desc.id);
3505
- }
3506
- }
3507
- const corruptFiles = [...fresh.corruptFiles, ...legacy.corruptFiles];
3490
+ const corruptFiles = [...fresh.corruptFiles];
3508
3491
  for (const corruptPath of corruptFiles) {
3509
3492
  for (const [, replica] of this.replicaBackends) {
3510
3493
  try {
@@ -3569,20 +3552,18 @@ var ConfigRepo = class {
3569
3552
  return result;
3570
3553
  }
3571
3554
  /**
3572
- * Write a single backend descriptor to `.config/backends/{id}.json`,
3573
- * mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
3574
- * so older clients still see the backend.
3555
+ * Write a single backend descriptor to `.meta/backends/{id}.json`.
3575
3556
  *
3576
- * Both files use the canonical serializer and are only written when their
3577
- * bytes actually differ (no needless sync churn).
3557
+ * Uses the canonical serializer and is only written when the bytes actually
3558
+ * differ (no needless sync churn). `/.config/backends/` is never written.
3578
3559
  */
3579
3560
  async writeBackendDescriptor(desc) {
3580
3561
  assertValidBackendId(desc.id);
3581
3562
  const author = `${this.appId}/${this.nodeId}`;
3582
3563
  const text = serializeBackendDescriptor(desc);
3583
3564
  const bytes = new TextEncoder().encode(text);
3584
- for (const path of [this.backendFilePath(desc.id), this.legacyBackendFilePath(desc.id)]) {
3585
- if (await this.readTextIfExists(path) === text) continue;
3565
+ const path = this.backendFilePath(desc.id);
3566
+ if (await this.readTextIfExists(path) !== text) {
3586
3567
  await this.ensureDir(path);
3587
3568
  await this.cachedFS.writeFile(path, bytes);
3588
3569
  const version = await incrementVersion(this.fullFS, path, bytes, author);
@@ -3592,7 +3573,10 @@ var ConfigRepo = class {
3592
3573
  if (existing >= 0) this.backendDescriptorCache[existing] = { ...desc };
3593
3574
  else this.backendDescriptorCache.push({ ...desc });
3594
3575
  }
3595
- /** Remove a single backend descriptor file + its version sidecar (both layouts) */
3576
+ /**
3577
+ * Remove a single backend descriptor: always `.meta/backends/{id}.json`, plus
3578
+ * a best-effort cleanup of the legacy `/.config/backends/{id}.json` residue.
3579
+ */
3596
3580
  async removeBackendDescriptor(id) {
3597
3581
  for (const path of [this.backendFilePath(id), this.legacyBackendFilePath(id)]) {
3598
3582
  try {
@@ -3879,8 +3863,9 @@ var ConfigRepo = class {
3879
3863
  return `${LEGACY_APP_DATA_GROUPS_DIR}/${this.appId}/${id}.json`;
3880
3864
  }
3881
3865
  /**
3882
- * Write a data-group descriptor to `.config/` (bootstrap copy), mirroring to
3883
- * the legacy `.meta/` path.
3866
+ * Write a data-group descriptor to `.config/app-data-groups/` (registration
3867
+ * + bootstrap copy). The legacy `.meta/app-data-groups/` mirror is no longer
3868
+ * written; it is still read so old layouts keep working.
3884
3869
  *
3885
3870
  * 这份描述符是**引导副本**:它让只有配置组凭据的新设备知道有哪些数据组、
3886
3871
  * 远端在哪。权威定义在数据组自己的 `.meta/backends/`。
@@ -3893,13 +3878,12 @@ var ConfigRepo = class {
3893
3878
  const text = serializeAppDataGroupDescriptor(mergeDescriptorCreatedAt(descriptor, existing));
3894
3879
  const bytes = new TextEncoder().encode(text);
3895
3880
  const author = `${this.appId}/${this.nodeId}`;
3896
- for (const descPath of [this.appDataGroupFilePath(id), this.legacyAppDataGroupFilePath(id)]) {
3897
- if (await this.readTextIfExists(descPath) === text) continue;
3898
- await this.ensureDir(descPath);
3899
- await this.cachedFS.writeFile(descPath, bytes);
3900
- const version = await incrementVersion(this.fullFS, descPath, bytes, author);
3901
- await this.writeVersionSidecar(descPath, version);
3902
- }
3881
+ const descPath = this.appDataGroupFilePath(id);
3882
+ if (await this.readTextIfExists(descPath) === text) return;
3883
+ await this.ensureDir(descPath);
3884
+ await this.cachedFS.writeFile(descPath, bytes);
3885
+ const version = await incrementVersion(this.fullFS, descPath, bytes, author);
3886
+ await this.writeVersionSidecar(descPath, version);
3903
3887
  }
3904
3888
  /**
3905
3889
  * Resolve a backend descriptor's options by merging account fields
package/dist/index.mjs CHANGED
@@ -1162,12 +1162,13 @@ function mergeTombstone(byPath, tombstone) {
1162
1162
  }
1163
1163
  async function readTombstonesFromFs(fs, warn) {
1164
1164
  const byPath = /* @__PURE__ */ new Map();
1165
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1165
+ {
1166
+ const dir = TOMBSTONES_DIR;
1166
1167
  let entries;
1167
1168
  try {
1168
1169
  entries = await fs.readdir(dir);
1169
1170
  } catch {
1170
- continue;
1171
+ return [];
1171
1172
  }
1172
1173
  for (const entry of entries) {
1173
1174
  if (!entry.endsWith(".json")) continue;
@@ -1263,43 +1264,34 @@ var TombstoneStore = class {
1263
1264
  }
1264
1265
  fs;
1265
1266
  author;
1266
- pathFor(filePath, dir = TOMBSTONES_DIR) {
1267
- return `${dir}/${encodeMetaPath(filePath)}.json`;
1267
+ pathFor(filePath) {
1268
+ return `${TOMBSTONES_DIR}/${encodeMetaPath(filePath)}.json`;
1268
1269
  }
1269
- /** All tombstones, new path first, legacy only for paths not already seen. */
1270
+ /** All tombstones. */
1270
1271
  async list() {
1271
1272
  return readTombstonesFromFs(this.fs, (message) => log2.warn(message));
1272
1273
  }
1273
- /** Write a tombstone (new + legacy mirror). */
1274
+ /** Write a tombstone. */
1274
1275
  async write(tombstone) {
1275
1276
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
1276
- const paths = [
1277
- this.pathFor(tombstone.path),
1278
- this.pathFor(tombstone.path, LEGACY_TOMBSTONES_DIR)
1279
- ];
1280
- for (const p of paths) {
1281
- await ensureParentDir2(this.fs, p);
1282
- await this.fs.writeFile(p, bytes);
1283
- }
1277
+ const p = this.pathFor(tombstone.path);
1278
+ await ensureParentDir2(this.fs, p);
1279
+ await this.fs.writeFile(p, bytes);
1284
1280
  }
1285
- /** Persist an updated tombstone (confirmations) to whichever paths exist. */
1281
+ /** Persist an updated tombstone (confirmations) when it still exists. */
1286
1282
  async save(tombstone) {
1287
1283
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
1288
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1289
- const p = this.pathFor(tombstone.path, dir);
1290
- if (!await existsSafe(this.fs, p)) continue;
1291
- await this.fs.writeFile(p, bytes);
1292
- }
1284
+ const p = this.pathFor(tombstone.path);
1285
+ if (!await existsSafe(this.fs, p)) return;
1286
+ await this.fs.writeFile(p, bytes);
1293
1287
  }
1294
- /** Delete a tombstone from both layouts. */
1288
+ /** Delete a tombstone. */
1295
1289
  async remove(tombstone) {
1296
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1297
- const p = this.pathFor(tombstone.path, dir);
1298
- if (!await existsSafe(this.fs, p)) continue;
1299
- try {
1300
- await this.fs.unlink(p);
1301
- } catch {
1302
- }
1290
+ const p = this.pathFor(tombstone.path);
1291
+ if (!await existsSafe(this.fs, p)) return;
1292
+ try {
1293
+ await this.fs.unlink(p);
1294
+ } catch {
1303
1295
  }
1304
1296
  }
1305
1297
  /**
@@ -1343,28 +1335,26 @@ var TombstoneStore = class {
1343
1335
  }
1344
1336
  return modified;
1345
1337
  }
1346
- /** Remove tombstones confirmed by every connected backend (and their mirrors). */
1338
+ /** Remove tombstones confirmed by every connected backend. */
1347
1339
  async gc(allBackendIds, targets = []) {
1348
1340
  const tombstones = await this.list();
1349
1341
  for (const tombstone of tombstones) {
1350
1342
  const allConfirmed = allBackendIds.every((id) => tombstone.confirmedBy.includes(id));
1351
1343
  if (!allConfirmed) continue;
1352
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1353
- const p = this.pathFor(tombstone.path, dir);
1354
- if (await existsSafe(this.fs, p)) {
1344
+ const p = this.pathFor(tombstone.path);
1345
+ if (await existsSafe(this.fs, p)) {
1346
+ try {
1347
+ await this.fs.unlink(p);
1348
+ } catch {
1349
+ }
1350
+ }
1351
+ for (const target of targets) {
1352
+ if (await existsSafe(target.fs, p)) {
1355
1353
  try {
1356
- await this.fs.unlink(p);
1354
+ await target.fs.unlink(p);
1357
1355
  } catch {
1358
1356
  }
1359
1357
  }
1360
- for (const target of targets) {
1361
- if (await existsSafe(target.fs, p)) {
1362
- try {
1363
- await target.fs.unlink(p);
1364
- } catch {
1365
- }
1366
- }
1367
- }
1368
1358
  }
1369
1359
  }
1370
1360
  }
@@ -1505,8 +1495,8 @@ var GROUP_DESCRIPTOR_FILE2 = `${META_DIR}/group.json`;
1505
1495
  var GROUP_TYPE_FILE = `${CONFIG_DIR}/group-type`;
1506
1496
  var LEGACY_GROUP_TYPE_FILE = `${META_DIR}/group-type`;
1507
1497
  var BACKENDS_FILE = `${META_DIR}/backends.json`;
1508
- var BACKENDS_DIR = `${CONFIG_DIR}/backends`;
1509
- var LEGACY_BACKENDS_DIR = META_BACKENDS_DIR;
1498
+ var BACKENDS_DIR = META_BACKENDS_DIR;
1499
+ var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
1510
1500
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
1511
1501
  var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
1512
1502
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
@@ -1892,9 +1882,9 @@ var ConfigRepo = class {
1892
1882
  // Tombstone (Deletion Tracking)
1893
1883
  // -----------------------------------------------------------------------
1894
1884
  /**
1895
- * Write the tombstone record for `filePath` (new `.meta/tombstones` + legacy
1896
- * mirror for one release cycle). Records only metadata — it never creates
1897
- * the deleted file locally.
1885
+ * Write the tombstone record for `filePath` under `.meta/tombstones/`.
1886
+ * Records only metadata — it never creates the deleted file locally, and the
1887
+ * legacy `/.meta/.deleted/` archive is neither read nor written.
1898
1888
  */
1899
1889
  async writeTombstoneFor(filePath) {
1900
1890
  const normalizedPath = filePath.startsWith("/") ? filePath : "/" + filePath;
@@ -1905,11 +1895,9 @@ var ConfigRepo = class {
1905
1895
  confirmedBy: [this.primaryBackendId]
1906
1896
  };
1907
1897
  const tombstoneBytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
1908
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
1909
- const tombstonePath = tombstonePathFor(normalizedPath, dir);
1910
- await this.ensureDir(tombstonePath);
1911
- await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
1912
- }
1898
+ const tombstonePath = tombstonePathFor(normalizedPath, TOMBSTONES_DIR);
1899
+ await this.ensureDir(tombstonePath);
1900
+ await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
1913
1901
  }
1914
1902
  /**
1915
1903
  * Delete a file and write a tombstone so the deletion propagates
@@ -2354,11 +2342,9 @@ var ConfigRepo = class {
2354
2342
  if (changed) {
2355
2343
  try {
2356
2344
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
2357
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
2358
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
2359
- if (await this.safeExists(this.cachedFS, tombstonePath)) {
2360
- await this.cachedFS.writeFile(tombstonePath, bytes);
2361
- }
2345
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
2346
+ if (await this.safeExists(this.cachedFS, tombstonePath)) {
2347
+ await this.cachedFS.writeFile(tombstonePath, bytes);
2362
2348
  }
2363
2349
  modified++;
2364
2350
  } catch {
@@ -2406,22 +2392,20 @@ var ConfigRepo = class {
2406
2392
  for (const tombstone of tombstones) {
2407
2393
  const allConfirmed = await this.allReplicasConfirmAbsent(tombstone.path);
2408
2394
  if (allConfirmed) {
2409
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
2410
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
2411
- try {
2412
- await this.cachedFS.unlink(tombstonePath);
2413
- } catch {
2414
- }
2415
- for (const [, replica] of this.replicaBackends) {
2416
- if (await this.safeExists(replica.instance, tombstonePath)) {
2417
- try {
2418
- await replica.instance.unlink(tombstonePath);
2419
- } catch {
2420
- }
2395
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
2396
+ try {
2397
+ await this.cachedFS.unlink(tombstonePath);
2398
+ } catch {
2399
+ }
2400
+ for (const [, replica] of this.replicaBackends) {
2401
+ if (await this.safeExists(replica.instance, tombstonePath)) {
2402
+ try {
2403
+ await replica.instance.unlink(tombstonePath);
2404
+ } catch {
2421
2405
  }
2422
2406
  }
2423
- log3.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
2424
2407
  }
2408
+ log3.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
2425
2409
  }
2426
2410
  }
2427
2411
  }
@@ -2485,7 +2469,7 @@ var ConfigRepo = class {
2485
2469
  this.assertNotDisposed();
2486
2470
  return [...this.backendDescriptorCache];
2487
2471
  }
2488
- /** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
2472
+ /** 配置组的权威后端列表(`.meta/backends/`),与 `listBackends()` 相同。 */
2489
2473
  listDeclaredBackends() {
2490
2474
  return this.listBackends();
2491
2475
  }
@@ -2878,11 +2862,15 @@ var ConfigRepo = class {
2878
2862
  // -----------------------------------------------------------------------
2879
2863
  // Internal — Individual Backend Descriptor Files
2880
2864
  // -----------------------------------------------------------------------
2881
- /** Path for a single backend descriptor: .config/backends/{id}.json */
2865
+ /** Path for a single backend descriptor: `.meta/backends/{id}.json`. */
2882
2866
  backendFilePath(id) {
2883
2867
  return `${BACKENDS_DIR}/${id}.json`;
2884
2868
  }
2885
- /** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
2869
+ /**
2870
+ * Legacy pre-0.7 path `/.config/backends/{id}.json`.
2871
+ *
2872
+ * 该目录已不再读取:此处只用于删除后端时尽力清理残留副本。
2873
+ */
2886
2874
  legacyBackendFilePath(id) {
2887
2875
  return `${LEGACY_BACKENDS_DIR}/${id}.json`;
2888
2876
  }
@@ -2931,8 +2919,11 @@ var ConfigRepo = class {
2931
2919
  return { items, corruptFiles };
2932
2920
  }
2933
2921
  /**
2934
- * Read all backend descriptors from `.config/backends/*.json` with legacy
2935
- * `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
2922
+ * Read all backend descriptors from `.meta/backends/*.json` — the single
2923
+ * authoritative location for both config-sync and data-sync groups.
2924
+ *
2925
+ * `/.config/backends/` is intentionally **not** read: leftovers there are
2926
+ * plain content and never take part in backend enumeration.
2936
2927
  *
2937
2928
  * If duplicate backends are detected (same type + options but different id),
2938
2929
  * only the first one (sorted by id) is kept and the rest are removed
@@ -2940,16 +2931,8 @@ var ConfigRepo = class {
2940
2931
  */
2941
2932
  async readAllBackendDescriptors() {
2942
2933
  const fresh = await this.readBackendDescriptorsFrom(BACKENDS_DIR);
2943
- const legacy = await this.readBackendDescriptorsFrom(LEGACY_BACKENDS_DIR);
2944
2934
  const items = [...fresh.items];
2945
- const seenIds = new Set(items.map((i) => i.desc.id));
2946
- for (const item of legacy.items) {
2947
- if (!seenIds.has(item.desc.id)) {
2948
- items.push(item);
2949
- seenIds.add(item.desc.id);
2950
- }
2951
- }
2952
- const corruptFiles = [...fresh.corruptFiles, ...legacy.corruptFiles];
2935
+ const corruptFiles = [...fresh.corruptFiles];
2953
2936
  for (const corruptPath of corruptFiles) {
2954
2937
  for (const [, replica] of this.replicaBackends) {
2955
2938
  try {
@@ -3014,20 +2997,18 @@ var ConfigRepo = class {
3014
2997
  return result;
3015
2998
  }
3016
2999
  /**
3017
- * Write a single backend descriptor to `.config/backends/{id}.json`,
3018
- * mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
3019
- * so older clients still see the backend.
3000
+ * Write a single backend descriptor to `.meta/backends/{id}.json`.
3020
3001
  *
3021
- * Both files use the canonical serializer and are only written when their
3022
- * bytes actually differ (no needless sync churn).
3002
+ * Uses the canonical serializer and is only written when the bytes actually
3003
+ * differ (no needless sync churn). `/.config/backends/` is never written.
3023
3004
  */
3024
3005
  async writeBackendDescriptor(desc) {
3025
3006
  assertValidBackendId(desc.id);
3026
3007
  const author = `${this.appId}/${this.nodeId}`;
3027
3008
  const text = serializeBackendDescriptor(desc);
3028
3009
  const bytes = new TextEncoder().encode(text);
3029
- for (const path of [this.backendFilePath(desc.id), this.legacyBackendFilePath(desc.id)]) {
3030
- if (await this.readTextIfExists(path) === text) continue;
3010
+ const path = this.backendFilePath(desc.id);
3011
+ if (await this.readTextIfExists(path) !== text) {
3031
3012
  await this.ensureDir(path);
3032
3013
  await this.cachedFS.writeFile(path, bytes);
3033
3014
  const version = await incrementVersion(this.fullFS, path, bytes, author);
@@ -3037,7 +3018,10 @@ var ConfigRepo = class {
3037
3018
  if (existing >= 0) this.backendDescriptorCache[existing] = { ...desc };
3038
3019
  else this.backendDescriptorCache.push({ ...desc });
3039
3020
  }
3040
- /** Remove a single backend descriptor file + its version sidecar (both layouts) */
3021
+ /**
3022
+ * Remove a single backend descriptor: always `.meta/backends/{id}.json`, plus
3023
+ * a best-effort cleanup of the legacy `/.config/backends/{id}.json` residue.
3024
+ */
3041
3025
  async removeBackendDescriptor(id) {
3042
3026
  for (const path of [this.backendFilePath(id), this.legacyBackendFilePath(id)]) {
3043
3027
  try {
@@ -3324,8 +3308,9 @@ var ConfigRepo = class {
3324
3308
  return `${LEGACY_APP_DATA_GROUPS_DIR}/${this.appId}/${id}.json`;
3325
3309
  }
3326
3310
  /**
3327
- * Write a data-group descriptor to `.config/` (bootstrap copy), mirroring to
3328
- * the legacy `.meta/` path.
3311
+ * Write a data-group descriptor to `.config/app-data-groups/` (registration
3312
+ * + bootstrap copy). The legacy `.meta/app-data-groups/` mirror is no longer
3313
+ * written; it is still read so old layouts keep working.
3329
3314
  *
3330
3315
  * 这份描述符是**引导副本**:它让只有配置组凭据的新设备知道有哪些数据组、
3331
3316
  * 远端在哪。权威定义在数据组自己的 `.meta/backends/`。
@@ -3338,13 +3323,12 @@ var ConfigRepo = class {
3338
3323
  const text = serializeAppDataGroupDescriptor(mergeDescriptorCreatedAt(descriptor, existing));
3339
3324
  const bytes = new TextEncoder().encode(text);
3340
3325
  const author = `${this.appId}/${this.nodeId}`;
3341
- for (const descPath of [this.appDataGroupFilePath(id), this.legacyAppDataGroupFilePath(id)]) {
3342
- if (await this.readTextIfExists(descPath) === text) continue;
3343
- await this.ensureDir(descPath);
3344
- await this.cachedFS.writeFile(descPath, bytes);
3345
- const version = await incrementVersion(this.fullFS, descPath, bytes, author);
3346
- await this.writeVersionSidecar(descPath, version);
3347
- }
3326
+ const descPath = this.appDataGroupFilePath(id);
3327
+ if (await this.readTextIfExists(descPath) === text) return;
3328
+ await this.ensureDir(descPath);
3329
+ await this.cachedFS.writeFile(descPath, bytes);
3330
+ const version = await incrementVersion(this.fullFS, descPath, bytes, author);
3331
+ await this.writeVersionSidecar(descPath, version);
3348
3332
  }
3349
3333
  /**
3350
3334
  * Resolve a backend descriptor's options by merging account fields
@@ -27739,12 +27739,13 @@ var ZenFSConfig = (() => {
27739
27739
  }
27740
27740
  async function readTombstonesFromFs(fs, warn2) {
27741
27741
  const byPath = /* @__PURE__ */ new Map();
27742
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
27742
+ {
27743
+ const dir = TOMBSTONES_DIR;
27743
27744
  let entries2;
27744
27745
  try {
27745
27746
  entries2 = await fs.readdir(dir);
27746
27747
  } catch {
27747
- continue;
27748
+ return [];
27748
27749
  }
27749
27750
  for (const entry of entries2) {
27750
27751
  if (!entry.endsWith(".json")) continue;
@@ -27838,43 +27839,34 @@ var ZenFSConfig = (() => {
27838
27839
  __publicField(this, "fs", fs);
27839
27840
  __publicField(this, "author", author);
27840
27841
  }
27841
- pathFor(filePath, dir = TOMBSTONES_DIR) {
27842
- return `${dir}/${encodeMetaPath(filePath)}.json`;
27842
+ pathFor(filePath) {
27843
+ return `${TOMBSTONES_DIR}/${encodeMetaPath(filePath)}.json`;
27843
27844
  }
27844
- /** All tombstones, new path first, legacy only for paths not already seen. */
27845
+ /** All tombstones. */
27845
27846
  async list() {
27846
27847
  return readTombstonesFromFs(this.fs, (message) => log6.warn(message));
27847
27848
  }
27848
- /** Write a tombstone (new + legacy mirror). */
27849
+ /** Write a tombstone. */
27849
27850
  async write(tombstone) {
27850
27851
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
27851
- const paths = [
27852
- this.pathFor(tombstone.path),
27853
- this.pathFor(tombstone.path, LEGACY_TOMBSTONES_DIR)
27854
- ];
27855
- for (const p of paths) {
27856
- await ensureParentDir2(this.fs, p);
27857
- await this.fs.writeFile(p, bytes);
27858
- }
27852
+ const p = this.pathFor(tombstone.path);
27853
+ await ensureParentDir2(this.fs, p);
27854
+ await this.fs.writeFile(p, bytes);
27859
27855
  }
27860
- /** Persist an updated tombstone (confirmations) to whichever paths exist. */
27856
+ /** Persist an updated tombstone (confirmations) when it still exists. */
27861
27857
  async save(tombstone) {
27862
27858
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
27863
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
27864
- const p = this.pathFor(tombstone.path, dir);
27865
- if (!await existsSafe(this.fs, p)) continue;
27866
- await this.fs.writeFile(p, bytes);
27867
- }
27859
+ const p = this.pathFor(tombstone.path);
27860
+ if (!await existsSafe(this.fs, p)) return;
27861
+ await this.fs.writeFile(p, bytes);
27868
27862
  }
27869
- /** Delete a tombstone from both layouts. */
27863
+ /** Delete a tombstone. */
27870
27864
  async remove(tombstone) {
27871
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
27872
- const p = this.pathFor(tombstone.path, dir);
27873
- if (!await existsSafe(this.fs, p)) continue;
27874
- try {
27875
- await this.fs.unlink(p);
27876
- } catch {
27877
- }
27865
+ const p = this.pathFor(tombstone.path);
27866
+ if (!await existsSafe(this.fs, p)) return;
27867
+ try {
27868
+ await this.fs.unlink(p);
27869
+ } catch {
27878
27870
  }
27879
27871
  }
27880
27872
  /**
@@ -27918,28 +27910,26 @@ var ZenFSConfig = (() => {
27918
27910
  }
27919
27911
  return modified;
27920
27912
  }
27921
- /** Remove tombstones confirmed by every connected backend (and their mirrors). */
27913
+ /** Remove tombstones confirmed by every connected backend. */
27922
27914
  async gc(allBackendIds, targets = []) {
27923
27915
  const tombstones = await this.list();
27924
27916
  for (const tombstone of tombstones) {
27925
27917
  const allConfirmed = allBackendIds.every((id) => tombstone.confirmedBy.includes(id));
27926
27918
  if (!allConfirmed) continue;
27927
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
27928
- const p = this.pathFor(tombstone.path, dir);
27929
- if (await existsSafe(this.fs, p)) {
27919
+ const p = this.pathFor(tombstone.path);
27920
+ if (await existsSafe(this.fs, p)) {
27921
+ try {
27922
+ await this.fs.unlink(p);
27923
+ } catch {
27924
+ }
27925
+ }
27926
+ for (const target of targets) {
27927
+ if (await existsSafe(target.fs, p)) {
27930
27928
  try {
27931
- await this.fs.unlink(p);
27929
+ await target.fs.unlink(p);
27932
27930
  } catch {
27933
27931
  }
27934
27932
  }
27935
- for (const target of targets) {
27936
- if (await existsSafe(target.fs, p)) {
27937
- try {
27938
- await target.fs.unlink(p);
27939
- } catch {
27940
- }
27941
- }
27942
- }
27943
27933
  }
27944
27934
  }
27945
27935
  }
@@ -28074,8 +28064,8 @@ var ZenFSConfig = (() => {
28074
28064
  var GROUP_TYPE_FILE = `${CONFIG_DIR}/group-type`;
28075
28065
  var LEGACY_GROUP_TYPE_FILE = `${META_DIR}/group-type`;
28076
28066
  var BACKENDS_FILE = `${META_DIR}/backends.json`;
28077
- var BACKENDS_DIR = `${CONFIG_DIR}/backends`;
28078
- var LEGACY_BACKENDS_DIR = META_BACKENDS_DIR;
28067
+ var BACKENDS_DIR = META_BACKENDS_DIR;
28068
+ var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
28079
28069
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
28080
28070
  var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
28081
28071
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
@@ -28467,9 +28457,9 @@ var ZenFSConfig = (() => {
28467
28457
  // Tombstone (Deletion Tracking)
28468
28458
  // -----------------------------------------------------------------------
28469
28459
  /**
28470
- * Write the tombstone record for `filePath` (new `.meta/tombstones` + legacy
28471
- * mirror for one release cycle). Records only metadata — it never creates
28472
- * the deleted file locally.
28460
+ * Write the tombstone record for `filePath` under `.meta/tombstones/`.
28461
+ * Records only metadata — it never creates the deleted file locally, and the
28462
+ * legacy `/.meta/.deleted/` archive is neither read nor written.
28473
28463
  */
28474
28464
  async writeTombstoneFor(filePath) {
28475
28465
  const normalizedPath = filePath.startsWith("/") ? filePath : "/" + filePath;
@@ -28480,11 +28470,9 @@ var ZenFSConfig = (() => {
28480
28470
  confirmedBy: [this.primaryBackendId]
28481
28471
  };
28482
28472
  const tombstoneBytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
28483
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
28484
- const tombstonePath = tombstonePathFor(normalizedPath, dir);
28485
- await this.ensureDir(tombstonePath);
28486
- await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
28487
- }
28473
+ const tombstonePath = tombstonePathFor(normalizedPath, TOMBSTONES_DIR);
28474
+ await this.ensureDir(tombstonePath);
28475
+ await this.cachedFS.writeFile(tombstonePath, tombstoneBytes);
28488
28476
  }
28489
28477
  /**
28490
28478
  * Delete a file and write a tombstone so the deletion propagates
@@ -28923,11 +28911,9 @@ var ZenFSConfig = (() => {
28923
28911
  if (changed) {
28924
28912
  try {
28925
28913
  const bytes = new TextEncoder().encode(JSON.stringify(tombstone, null, 2));
28926
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
28927
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
28928
- if (await this.safeExists(this.cachedFS, tombstonePath)) {
28929
- await this.cachedFS.writeFile(tombstonePath, bytes);
28930
- }
28914
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
28915
+ if (await this.safeExists(this.cachedFS, tombstonePath)) {
28916
+ await this.cachedFS.writeFile(tombstonePath, bytes);
28931
28917
  }
28932
28918
  modified++;
28933
28919
  } catch {
@@ -28975,22 +28961,20 @@ var ZenFSConfig = (() => {
28975
28961
  for (const tombstone of tombstones) {
28976
28962
  const allConfirmed = await this.allReplicasConfirmAbsent(tombstone.path);
28977
28963
  if (allConfirmed) {
28978
- for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
28979
- const tombstonePath = tombstonePathFor(tombstone.path, dir);
28980
- try {
28981
- await this.cachedFS.unlink(tombstonePath);
28982
- } catch {
28983
- }
28984
- for (const [, replica] of this.replicaBackends) {
28985
- if (await this.safeExists(replica.instance, tombstonePath)) {
28986
- try {
28987
- await replica.instance.unlink(tombstonePath);
28988
- } catch {
28989
- }
28964
+ const tombstonePath = tombstonePathFor(tombstone.path, TOMBSTONES_DIR);
28965
+ try {
28966
+ await this.cachedFS.unlink(tombstonePath);
28967
+ } catch {
28968
+ }
28969
+ for (const [, replica] of this.replicaBackends) {
28970
+ if (await this.safeExists(replica.instance, tombstonePath)) {
28971
+ try {
28972
+ await replica.instance.unlink(tombstonePath);
28973
+ } catch {
28990
28974
  }
28991
28975
  }
28992
- log7.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
28993
28976
  }
28977
+ log7.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
28994
28978
  }
28995
28979
  }
28996
28980
  }
@@ -29054,7 +29038,7 @@ var ZenFSConfig = (() => {
29054
29038
  this.assertNotDisposed();
29055
29039
  return [...this.backendDescriptorCache];
29056
29040
  }
29057
- /** 配置组的权威后端列表(`.config/backends/`),与 `listBackends()` 相同。 */
29041
+ /** 配置组的权威后端列表(`.meta/backends/`),与 `listBackends()` 相同。 */
29058
29042
  listDeclaredBackends() {
29059
29043
  return this.listBackends();
29060
29044
  }
@@ -29447,11 +29431,15 @@ var ZenFSConfig = (() => {
29447
29431
  // -----------------------------------------------------------------------
29448
29432
  // Internal — Individual Backend Descriptor Files
29449
29433
  // -----------------------------------------------------------------------
29450
- /** Path for a single backend descriptor: .config/backends/{id}.json */
29434
+ /** Path for a single backend descriptor: `.meta/backends/{id}.json`. */
29451
29435
  backendFilePath(id) {
29452
29436
  return `${BACKENDS_DIR}/${id}.json`;
29453
29437
  }
29454
- /** Legacy path: .meta/backends/{id}.json (read + dual-write for one cycle). */
29438
+ /**
29439
+ * Legacy pre-0.7 path `/.config/backends/{id}.json`.
29440
+ *
29441
+ * 该目录已不再读取:此处只用于删除后端时尽力清理残留副本。
29442
+ */
29455
29443
  legacyBackendFilePath(id) {
29456
29444
  return `${LEGACY_BACKENDS_DIR}/${id}.json`;
29457
29445
  }
@@ -29500,8 +29488,11 @@ var ZenFSConfig = (() => {
29500
29488
  return { items, corruptFiles };
29501
29489
  }
29502
29490
  /**
29503
- * Read all backend descriptors from `.config/backends/*.json` with legacy
29504
- * `.meta/backends/*.json` as a one-cycle fallback (new layout wins by id).
29491
+ * Read all backend descriptors from `.meta/backends/*.json` — the single
29492
+ * authoritative location for both config-sync and data-sync groups.
29493
+ *
29494
+ * `/.config/backends/` is intentionally **not** read: leftovers there are
29495
+ * plain content and never take part in backend enumeration.
29505
29496
  *
29506
29497
  * If duplicate backends are detected (same type + options but different id),
29507
29498
  * only the first one (sorted by id) is kept and the rest are removed
@@ -29509,16 +29500,8 @@ var ZenFSConfig = (() => {
29509
29500
  */
29510
29501
  async readAllBackendDescriptors() {
29511
29502
  const fresh = await this.readBackendDescriptorsFrom(BACKENDS_DIR);
29512
- const legacy = await this.readBackendDescriptorsFrom(LEGACY_BACKENDS_DIR);
29513
29503
  const items = [...fresh.items];
29514
- const seenIds = new Set(items.map((i) => i.desc.id));
29515
- for (const item of legacy.items) {
29516
- if (!seenIds.has(item.desc.id)) {
29517
- items.push(item);
29518
- seenIds.add(item.desc.id);
29519
- }
29520
- }
29521
- const corruptFiles = [...fresh.corruptFiles, ...legacy.corruptFiles];
29504
+ const corruptFiles = [...fresh.corruptFiles];
29522
29505
  for (const corruptPath of corruptFiles) {
29523
29506
  for (const [, replica] of this.replicaBackends) {
29524
29507
  try {
@@ -29583,20 +29566,18 @@ var ZenFSConfig = (() => {
29583
29566
  return result;
29584
29567
  }
29585
29568
  /**
29586
- * Write a single backend descriptor to `.config/backends/{id}.json`,
29587
- * mirroring to the legacy `.meta/backends/{id}.json` for one release cycle
29588
- * so older clients still see the backend.
29569
+ * Write a single backend descriptor to `.meta/backends/{id}.json`.
29589
29570
  *
29590
- * Both files use the canonical serializer and are only written when their
29591
- * bytes actually differ (no needless sync churn).
29571
+ * Uses the canonical serializer and is only written when the bytes actually
29572
+ * differ (no needless sync churn). `/.config/backends/` is never written.
29592
29573
  */
29593
29574
  async writeBackendDescriptor(desc) {
29594
29575
  assertValidBackendId(desc.id);
29595
29576
  const author = `${this.appId}/${this.nodeId}`;
29596
29577
  const text = serializeBackendDescriptor(desc);
29597
29578
  const bytes = new TextEncoder().encode(text);
29598
- for (const path of [this.backendFilePath(desc.id), this.legacyBackendFilePath(desc.id)]) {
29599
- if (await this.readTextIfExists(path) === text) continue;
29579
+ const path = this.backendFilePath(desc.id);
29580
+ if (await this.readTextIfExists(path) !== text) {
29600
29581
  await this.ensureDir(path);
29601
29582
  await this.cachedFS.writeFile(path, bytes);
29602
29583
  const version2 = await incrementVersion(this.fullFS, path, bytes, author);
@@ -29606,7 +29587,10 @@ var ZenFSConfig = (() => {
29606
29587
  if (existing >= 0) this.backendDescriptorCache[existing] = { ...desc };
29607
29588
  else this.backendDescriptorCache.push({ ...desc });
29608
29589
  }
29609
- /** Remove a single backend descriptor file + its version sidecar (both layouts) */
29590
+ /**
29591
+ * Remove a single backend descriptor: always `.meta/backends/{id}.json`, plus
29592
+ * a best-effort cleanup of the legacy `/.config/backends/{id}.json` residue.
29593
+ */
29610
29594
  async removeBackendDescriptor(id) {
29611
29595
  for (const path of [this.backendFilePath(id), this.legacyBackendFilePath(id)]) {
29612
29596
  try {
@@ -29893,8 +29877,9 @@ var ZenFSConfig = (() => {
29893
29877
  return `${LEGACY_APP_DATA_GROUPS_DIR}/${this.appId}/${id}.json`;
29894
29878
  }
29895
29879
  /**
29896
- * Write a data-group descriptor to `.config/` (bootstrap copy), mirroring to
29897
- * the legacy `.meta/` path.
29880
+ * Write a data-group descriptor to `.config/app-data-groups/` (registration
29881
+ * + bootstrap copy). The legacy `.meta/app-data-groups/` mirror is no longer
29882
+ * written; it is still read so old layouts keep working.
29898
29883
  *
29899
29884
  * 这份描述符是**引导副本**:它让只有配置组凭据的新设备知道有哪些数据组、
29900
29885
  * 远端在哪。权威定义在数据组自己的 `.meta/backends/`。
@@ -29907,13 +29892,12 @@ var ZenFSConfig = (() => {
29907
29892
  const text = serializeAppDataGroupDescriptor(mergeDescriptorCreatedAt(descriptor, existing));
29908
29893
  const bytes = new TextEncoder().encode(text);
29909
29894
  const author = `${this.appId}/${this.nodeId}`;
29910
- for (const descPath of [this.appDataGroupFilePath(id), this.legacyAppDataGroupFilePath(id)]) {
29911
- if (await this.readTextIfExists(descPath) === text) continue;
29912
- await this.ensureDir(descPath);
29913
- await this.cachedFS.writeFile(descPath, bytes);
29914
- const version2 = await incrementVersion(this.fullFS, descPath, bytes, author);
29915
- await this.writeVersionSidecar(descPath, version2);
29916
- }
29895
+ const descPath = this.appDataGroupFilePath(id);
29896
+ if (await this.readTextIfExists(descPath) === text) return;
29897
+ await this.ensureDir(descPath);
29898
+ await this.cachedFS.writeFile(descPath, bytes);
29899
+ const version2 = await incrementVersion(this.fullFS, descPath, bytes, author);
29900
+ await this.writeVersionSidecar(descPath, version2);
29917
29901
  }
29918
29902
  /**
29919
29903
  * Resolve a backend descriptor's options by merging account fields
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",