zen-fs-config 0.6.1 → 0.6.2
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 +269 -177
- package/dist/index.mjs +269 -177
- package/dist/zen-fs-config.js +265 -176
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -978,7 +978,7 @@ async function defaultNodeDir(appId, kind, groupId) {
|
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
// src/config-repo.ts
|
|
981
|
-
var
|
|
981
|
+
var import_localstorage_logger3 = require("@richard432/localstorage-logger");
|
|
982
982
|
|
|
983
983
|
// src/version.ts
|
|
984
984
|
function versionPathFor(configFilePath) {
|
|
@@ -1464,6 +1464,9 @@ async function migrateVersionSidecars(fs, options = {}) {
|
|
|
1464
1464
|
return result;
|
|
1465
1465
|
}
|
|
1466
1466
|
|
|
1467
|
+
// src/group-meta.ts
|
|
1468
|
+
var import_localstorage_logger2 = require("@richard432/localstorage-logger");
|
|
1469
|
+
|
|
1467
1470
|
// src/canonical-json.ts
|
|
1468
1471
|
var FEATURE_ORDER = ["tombstones", "versions", "conflicts", "configHost", "appData"];
|
|
1469
1472
|
var GROUP_DESCRIPTOR_ORDER = ["schemaVersion", "kind", "id", "name", "features"];
|
|
@@ -1537,6 +1540,7 @@ function mergeDescriptorCreatedAt(descriptor, existing) {
|
|
|
1537
1540
|
}
|
|
1538
1541
|
|
|
1539
1542
|
// src/group-meta.ts
|
|
1543
|
+
var log2 = (0, import_localstorage_logger2.createLogger)("zen-fs-config:tombstones");
|
|
1540
1544
|
var META_DIR = "/.meta";
|
|
1541
1545
|
var GROUP_DESCRIPTOR_FILE = `${META_DIR}/group.json`;
|
|
1542
1546
|
var META_BACKENDS_DIR = `${META_DIR}/backends`;
|
|
@@ -1607,6 +1611,141 @@ function encodeMetaPath(filePath) {
|
|
|
1607
1611
|
const normalized = filePath.startsWith("/") ? filePath : `/${filePath}`;
|
|
1608
1612
|
return normalized.replace(/^\//, "").replace(/\//g, "__").replace(/\./g, "++");
|
|
1609
1613
|
}
|
|
1614
|
+
function decodeMetaPath(entry) {
|
|
1615
|
+
if (!entry.endsWith(".json")) return null;
|
|
1616
|
+
const encoded = entry.slice(0, -".json".length);
|
|
1617
|
+
if (!encoded) return null;
|
|
1618
|
+
return `/${encoded.replace(/__/g, "/").replace(/\+\+/g, ".")}`;
|
|
1619
|
+
}
|
|
1620
|
+
function fallbackTombstone(path) {
|
|
1621
|
+
return { path, deletedAt: 0, deletedBy: "unknown", confirmedBy: [] };
|
|
1622
|
+
}
|
|
1623
|
+
function normalizeTombstoneRecord(value, fallbackPath) {
|
|
1624
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1625
|
+
const record = value;
|
|
1626
|
+
const rawPath = typeof record.path === "string" ? record.path : fallbackPath;
|
|
1627
|
+
if (!rawPath) return null;
|
|
1628
|
+
const path = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
|
|
1629
|
+
const confirmedBy = Array.isArray(record.confirmedBy) ? record.confirmedBy.filter((id) => typeof id === "string") : [];
|
|
1630
|
+
return {
|
|
1631
|
+
path,
|
|
1632
|
+
deletedAt: typeof record.deletedAt === "number" ? record.deletedAt : 0,
|
|
1633
|
+
deletedBy: typeof record.deletedBy === "string" ? record.deletedBy : "unknown",
|
|
1634
|
+
confirmedBy
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function extractJsonObjects(raw) {
|
|
1638
|
+
const objects = [];
|
|
1639
|
+
let depth = 0;
|
|
1640
|
+
let start = -1;
|
|
1641
|
+
let inString = false;
|
|
1642
|
+
let escaped = false;
|
|
1643
|
+
for (let i = 0; i < raw.length; i++) {
|
|
1644
|
+
const ch = raw[i];
|
|
1645
|
+
if (inString) {
|
|
1646
|
+
if (escaped) escaped = false;
|
|
1647
|
+
else if (ch === "\\") escaped = true;
|
|
1648
|
+
else if (ch === '"') inString = false;
|
|
1649
|
+
continue;
|
|
1650
|
+
}
|
|
1651
|
+
if (ch === '"') {
|
|
1652
|
+
inString = true;
|
|
1653
|
+
continue;
|
|
1654
|
+
}
|
|
1655
|
+
if (ch === "{") {
|
|
1656
|
+
if (depth === 0) start = i;
|
|
1657
|
+
depth++;
|
|
1658
|
+
continue;
|
|
1659
|
+
}
|
|
1660
|
+
if (ch === "}") {
|
|
1661
|
+
if (depth === 0) continue;
|
|
1662
|
+
depth--;
|
|
1663
|
+
if (depth === 0 && start >= 0) {
|
|
1664
|
+
objects.push(raw.slice(start, i + 1));
|
|
1665
|
+
start = -1;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return objects;
|
|
1670
|
+
}
|
|
1671
|
+
function parseTombstoneFile(raw, fallbackPath) {
|
|
1672
|
+
const problems = [];
|
|
1673
|
+
const text = raw.trim();
|
|
1674
|
+
if (text === "") {
|
|
1675
|
+
problems.push("empty body");
|
|
1676
|
+
if (fallbackPath) {
|
|
1677
|
+
problems.push("path derived from filename");
|
|
1678
|
+
return { tombstones: [fallbackTombstone(fallbackPath)], problems };
|
|
1679
|
+
}
|
|
1680
|
+
problems.push("no path derivable from filename \u2014 skipped");
|
|
1681
|
+
return { tombstones: [], problems };
|
|
1682
|
+
}
|
|
1683
|
+
try {
|
|
1684
|
+
const parsed = normalizeTombstoneRecord(JSON.parse(text), fallbackPath);
|
|
1685
|
+
if (parsed) return { tombstones: [parsed], problems: [] };
|
|
1686
|
+
problems.push('JSON parsed but has no usable "path"');
|
|
1687
|
+
} catch (err) {
|
|
1688
|
+
problems.push(`JSON parse error: ${err instanceof Error ? err.message : String(err)}`);
|
|
1689
|
+
}
|
|
1690
|
+
const recovered = extractJsonObjects(text).map((chunk) => {
|
|
1691
|
+
try {
|
|
1692
|
+
return normalizeTombstoneRecord(JSON.parse(chunk));
|
|
1693
|
+
} catch {
|
|
1694
|
+
return null;
|
|
1695
|
+
}
|
|
1696
|
+
}).filter((t) => t !== null);
|
|
1697
|
+
if (recovered.length > 0) {
|
|
1698
|
+
if (recovered.length > 1) problems.push(`${recovered.length} concatenated documents recovered`);
|
|
1699
|
+
return { tombstones: recovered, problems };
|
|
1700
|
+
}
|
|
1701
|
+
if (fallbackPath) {
|
|
1702
|
+
problems.push("no recoverable document; path derived from filename");
|
|
1703
|
+
return { tombstones: [fallbackTombstone(fallbackPath)], problems };
|
|
1704
|
+
}
|
|
1705
|
+
problems.push("no recoverable document and no path derivable from filename \u2014 skipped");
|
|
1706
|
+
return { tombstones: [], problems };
|
|
1707
|
+
}
|
|
1708
|
+
function mergeTombstone(byPath, tombstone) {
|
|
1709
|
+
const prev = byPath.get(tombstone.path);
|
|
1710
|
+
if (!prev) {
|
|
1711
|
+
byPath.set(tombstone.path, tombstone);
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
for (const id of tombstone.confirmedBy) {
|
|
1715
|
+
if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
async function readTombstonesFromFs(fs, warn) {
|
|
1719
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1720
|
+
for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
|
|
1721
|
+
let entries;
|
|
1722
|
+
try {
|
|
1723
|
+
entries = await fs.readdir(dir);
|
|
1724
|
+
} catch {
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
for (const entry of entries) {
|
|
1728
|
+
if (!entry.endsWith(".json")) continue;
|
|
1729
|
+
const filePath = `${dir}/${entry}`;
|
|
1730
|
+
let raw;
|
|
1731
|
+
try {
|
|
1732
|
+
raw = new TextDecoder().decode(toBytes(await fs.readFile(filePath)));
|
|
1733
|
+
} catch (err) {
|
|
1734
|
+
warn(
|
|
1735
|
+
`[Tombstones] unreadable tombstone ${filePath}: ${err instanceof Error ? err.message : String(err)} \u2014 skipped`
|
|
1736
|
+
);
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1739
|
+
const { tombstones, problems } = parseTombstoneFile(raw, decodeMetaPath(entry) ?? void 0);
|
|
1740
|
+
if (problems.length > 0) {
|
|
1741
|
+
const action = tombstones.length > 0 ? tombstones.map((t) => `"${t.path}" treated as deleted`).join(", ") : "skipped";
|
|
1742
|
+
warn(`[Tombstones] corrupt tombstone ${filePath}: ${problems.join("; ")} \u2192 ${action}`);
|
|
1743
|
+
}
|
|
1744
|
+
for (const tombstone of tombstones) mergeTombstone(byPath, tombstone);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
return Array.from(byPath.values());
|
|
1748
|
+
}
|
|
1610
1749
|
async function readGroupDescriptor(fs) {
|
|
1611
1750
|
const parsed = await readJson(fs, GROUP_DESCRIPTOR_FILE);
|
|
1612
1751
|
if (!parsed) return null;
|
|
@@ -1684,29 +1823,7 @@ var TombstoneStore = class {
|
|
|
1684
1823
|
}
|
|
1685
1824
|
/** All tombstones, new path first, legacy only for paths not already seen. */
|
|
1686
1825
|
async list() {
|
|
1687
|
-
|
|
1688
|
-
for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
|
|
1689
|
-
let entries;
|
|
1690
|
-
try {
|
|
1691
|
-
entries = await this.fs.readdir(dir);
|
|
1692
|
-
} catch {
|
|
1693
|
-
continue;
|
|
1694
|
-
}
|
|
1695
|
-
for (const entry of entries) {
|
|
1696
|
-
if (!entry.endsWith(".json")) continue;
|
|
1697
|
-
const data = await readJson(this.fs, `${dir}/${entry}`);
|
|
1698
|
-
if (!data || typeof data.path !== "string") continue;
|
|
1699
|
-
const prev = byPath.get(data.path);
|
|
1700
|
-
if (prev) {
|
|
1701
|
-
for (const id of data.confirmedBy ?? []) {
|
|
1702
|
-
if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
|
|
1703
|
-
}
|
|
1704
|
-
} else {
|
|
1705
|
-
byPath.set(data.path, data);
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
return Array.from(byPath.values());
|
|
1826
|
+
return readTombstonesFromFs(this.fs, (message) => log2.warn(message));
|
|
1710
1827
|
}
|
|
1711
1828
|
/** Write a tombstone (new + legacy mirror). */
|
|
1712
1829
|
async write(tombstone) {
|
|
@@ -1938,7 +2055,7 @@ var ConflictStore = class {
|
|
|
1938
2055
|
};
|
|
1939
2056
|
|
|
1940
2057
|
// src/config-repo.ts
|
|
1941
|
-
var
|
|
2058
|
+
var log3 = (0, import_localstorage_logger3.createLogger)("zen-fs-config:config-repo");
|
|
1942
2059
|
var GROUP_DESCRIPTOR_FILE2 = `${META_DIR}/group.json`;
|
|
1943
2060
|
var GROUP_TYPE_FILE = `${CONFIG_DIR}/group-type`;
|
|
1944
2061
|
var LEGACY_GROUP_TYPE_FILE = `${META_DIR}/group-type`;
|
|
@@ -2191,7 +2308,7 @@ var ConfigRepo = class {
|
|
|
2191
2308
|
const bytes = this.serializer.serialize(data, fullPath);
|
|
2192
2309
|
this.configCache.set(fullPath, data);
|
|
2193
2310
|
this.persistConfig(fullPath, bytes).catch((err) => {
|
|
2194
|
-
|
|
2311
|
+
log3.error(`[zen-fs-config] Failed to persist ${fullPath}:`, err);
|
|
2195
2312
|
});
|
|
2196
2313
|
}
|
|
2197
2314
|
// -----------------------------------------------------------------------
|
|
@@ -2345,7 +2462,7 @@ var ConfigRepo = class {
|
|
|
2345
2462
|
await removeDirectoryTree(this.cachedFS, normalizedPath);
|
|
2346
2463
|
this.invalidateTombstoneCache();
|
|
2347
2464
|
this.schedulePostDeleteSync();
|
|
2348
|
-
|
|
2465
|
+
log3.log(`[ConfigRepo] deleteFile(directory): ${normalizedPath} (${files.length} file(s))`);
|
|
2349
2466
|
return;
|
|
2350
2467
|
}
|
|
2351
2468
|
await this.writeTombstoneFor(normalizedPath);
|
|
@@ -2366,7 +2483,7 @@ var ConfigRepo = class {
|
|
|
2366
2483
|
} catch {
|
|
2367
2484
|
}
|
|
2368
2485
|
}
|
|
2369
|
-
|
|
2486
|
+
log3.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePathFor(normalizedPath)})`);
|
|
2370
2487
|
this.invalidateTombstoneCache();
|
|
2371
2488
|
this.schedulePostDeleteSync();
|
|
2372
2489
|
}
|
|
@@ -2384,7 +2501,7 @@ var ConfigRepo = class {
|
|
|
2384
2501
|
this.postDeleteSyncTimer = void 0;
|
|
2385
2502
|
if (this.disposed) return;
|
|
2386
2503
|
this.syncEngine.syncAll().catch((err) => {
|
|
2387
|
-
|
|
2504
|
+
log3.warn("[ConfigRepo] post-delete sync failed:", err);
|
|
2388
2505
|
});
|
|
2389
2506
|
}, 500);
|
|
2390
2507
|
}
|
|
@@ -2396,32 +2513,7 @@ var ConfigRepo = class {
|
|
|
2396
2513
|
if (this.tombstoneCache !== null) {
|
|
2397
2514
|
return this.tombstoneCache;
|
|
2398
2515
|
}
|
|
2399
|
-
|
|
2400
|
-
for (const dir of [TOMBSTONES_DIR, LEGACY_TOMBSTONES_DIR]) {
|
|
2401
|
-
let entries;
|
|
2402
|
-
try {
|
|
2403
|
-
entries = await this.cachedFS.readdir(dir);
|
|
2404
|
-
} catch {
|
|
2405
|
-
continue;
|
|
2406
|
-
}
|
|
2407
|
-
for (const entry of entries) {
|
|
2408
|
-
if (!entry.endsWith(".json")) continue;
|
|
2409
|
-
try {
|
|
2410
|
-
const raw = await this.cachedFS.readFile(`${dir}/${entry}`);
|
|
2411
|
-
const data = JSON.parse(new TextDecoder().decode(toUint8Array2(raw)));
|
|
2412
|
-
const prev = byPath.get(data.path);
|
|
2413
|
-
if (prev) {
|
|
2414
|
-
for (const id of data.confirmedBy ?? []) {
|
|
2415
|
-
if (!prev.confirmedBy.includes(id)) prev.confirmedBy.push(id);
|
|
2416
|
-
}
|
|
2417
|
-
} else {
|
|
2418
|
-
byPath.set(data.path, data);
|
|
2419
|
-
}
|
|
2420
|
-
} catch {
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
this.tombstoneCache = Array.from(byPath.values());
|
|
2516
|
+
this.tombstoneCache = await readTombstonesFromFs(this.cachedFS, (message) => log3.warn(message));
|
|
2425
2517
|
return this.tombstoneCache;
|
|
2426
2518
|
}
|
|
2427
2519
|
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
@@ -2446,11 +2538,11 @@ var ConfigRepo = class {
|
|
|
2446
2538
|
for (const tombstone of tombstones) {
|
|
2447
2539
|
const forceDelete = isMtimeSidecar(tombstone.path);
|
|
2448
2540
|
const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
|
|
2449
|
-
|
|
2541
|
+
log3.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"} forceDelete=${forceDelete}`);
|
|
2450
2542
|
const existedOnPrimary = forceDelete || await this.safeExists(this.cachedFS, tombstone.path);
|
|
2451
|
-
|
|
2543
|
+
log3.log(`[TOMB-TRACE] primary safeExists(${tombstone.path}) \u2192 ${existedOnPrimary}`);
|
|
2452
2544
|
if (existedOnPrimary) {
|
|
2453
|
-
|
|
2545
|
+
log3.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on primary \u2192 EXISTS`);
|
|
2454
2546
|
}
|
|
2455
2547
|
if (existedOnPrimary) {
|
|
2456
2548
|
try {
|
|
@@ -2461,7 +2553,7 @@ var ConfigRepo = class {
|
|
|
2461
2553
|
}
|
|
2462
2554
|
if (tVersionPath) {
|
|
2463
2555
|
const vExistedOnPrimary = await this.safeExists(this.cachedFS, tVersionPath);
|
|
2464
|
-
|
|
2556
|
+
log3.log(`[TOMB-TRACE] primary safeExists(${tVersionPath}) \u2192 ${vExistedOnPrimary}`);
|
|
2465
2557
|
if (vExistedOnPrimary) {
|
|
2466
2558
|
try {
|
|
2467
2559
|
await this.cachedFS.unlink(tVersionPath);
|
|
@@ -2470,40 +2562,40 @@ var ConfigRepo = class {
|
|
|
2470
2562
|
}
|
|
2471
2563
|
}
|
|
2472
2564
|
for (const [replicaId, replica] of this.replicaBackends) {
|
|
2473
|
-
|
|
2565
|
+
log3.log(`[TOMB-TRACE] checking replica: ${replicaId} for ${tombstone.path}`);
|
|
2474
2566
|
const existed = forceDelete || await this.safeExists(replica.instance, tombstone.path);
|
|
2475
|
-
|
|
2567
|
+
log3.log(`[TOMB-TRACE] replica ${replicaId} safeExists(${tombstone.path}) \u2192 ${existed}`);
|
|
2476
2568
|
if (existed) {
|
|
2477
|
-
|
|
2569
|
+
log3.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on ${replicaId} \u2192 EXISTS`);
|
|
2478
2570
|
try {
|
|
2479
|
-
|
|
2571
|
+
log3.log(`[TOMB-TRACE] calling unlink(${tombstone.path}) on ${replicaId}`);
|
|
2480
2572
|
await replica.instance.unlink(tombstone.path);
|
|
2481
|
-
|
|
2573
|
+
log3.log(`[TOMB-TRACE] tombstone ${tombstone.path}: deleted on ${replicaId}`);
|
|
2482
2574
|
processed++;
|
|
2483
2575
|
} catch (err) {
|
|
2484
|
-
|
|
2576
|
+
log3.log(`[TOMB-TRACE] unlink(${tombstone.path}) on ${replicaId} FAILED: ${err}`);
|
|
2485
2577
|
alreadyDeleted++;
|
|
2486
2578
|
}
|
|
2487
2579
|
} else {
|
|
2488
|
-
|
|
2580
|
+
log3.log(`[TOMB-TRACE] replica ${replicaId}: already gone, skipping unlink`);
|
|
2489
2581
|
alreadyDeleted++;
|
|
2490
2582
|
}
|
|
2491
2583
|
if (tVersionPath) {
|
|
2492
2584
|
const vExisted = await this.safeExists(replica.instance, tVersionPath);
|
|
2493
|
-
|
|
2585
|
+
log3.log(`[TOMB-TRACE] replica ${replicaId} safeExists(${tVersionPath}) \u2192 ${vExisted}`);
|
|
2494
2586
|
if (vExisted) {
|
|
2495
2587
|
try {
|
|
2496
|
-
|
|
2588
|
+
log3.log(`[TOMB-TRACE] calling unlink(${tVersionPath}) on ${replicaId}`);
|
|
2497
2589
|
await replica.instance.unlink(tVersionPath);
|
|
2498
2590
|
} catch (err) {
|
|
2499
|
-
|
|
2591
|
+
log3.log(`[TOMB-TRACE] unlink(${tVersionPath}) on ${replicaId} FAILED: ${err}`);
|
|
2500
2592
|
}
|
|
2501
2593
|
}
|
|
2502
2594
|
}
|
|
2503
2595
|
}
|
|
2504
2596
|
}
|
|
2505
2597
|
if (processed > 0 || alreadyDeleted > 0) {
|
|
2506
|
-
|
|
2598
|
+
log3.log(`[TOMB-TRACE] processTombstones: ${tombstones.length} tombstone(s), ${processed} deleted, ${alreadyDeleted} already gone`);
|
|
2507
2599
|
}
|
|
2508
2600
|
}
|
|
2509
2601
|
/**
|
|
@@ -2519,21 +2611,21 @@ var ConfigRepo = class {
|
|
|
2519
2611
|
const innerBackendName = fs?.inner?.backendName;
|
|
2520
2612
|
const directBackendName = fs?.backendName;
|
|
2521
2613
|
const backendLabel = innerBackendName ?? directBackendName ?? innerBackend ?? ctorName;
|
|
2522
|
-
|
|
2614
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): fs type=${ctorName} backend=${backendLabel} hasExists=${hasExists} hasStat=${hasStat} inner=${innerBackend ?? "N/A"}`);
|
|
2523
2615
|
if (hasExists) {
|
|
2524
|
-
|
|
2616
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): \u2192 calling fs.exists() [backend=${backendLabel}]`);
|
|
2525
2617
|
const result = await fs.exists(path);
|
|
2526
|
-
|
|
2618
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): \u2190 fs.exists() [backend=${backendLabel}] \u2192 ${result}`);
|
|
2527
2619
|
return result;
|
|
2528
2620
|
}
|
|
2529
|
-
|
|
2621
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): no exists(), calling fs.stat() [backend=${backendLabel}]`);
|
|
2530
2622
|
await fs.stat(path);
|
|
2531
|
-
|
|
2623
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): \u2190 fs.stat() [backend=${backendLabel}] \u2192 OK (exists)`);
|
|
2532
2624
|
return true;
|
|
2533
2625
|
} catch (err) {
|
|
2534
2626
|
const errCode = err?.code ?? err?.status ?? "";
|
|
2535
2627
|
const errName = err?.constructor?.name ?? "";
|
|
2536
|
-
|
|
2628
|
+
log3.log(`[TOMB-TRACE] safeExists(${path}): \u2190 ERROR ${errName} ${errCode} ${err?.message ?? err}`);
|
|
2537
2629
|
return false;
|
|
2538
2630
|
}
|
|
2539
2631
|
}
|
|
@@ -2560,13 +2652,13 @@ var ConfigRepo = class {
|
|
|
2560
2652
|
this.assertNotDisposed();
|
|
2561
2653
|
const result = await purgeMtimeSidecars(this.cachedFS, options);
|
|
2562
2654
|
if (result.removed.length > 0) {
|
|
2563
|
-
|
|
2655
|
+
log3.log(
|
|
2564
2656
|
`[ConfigRepo] purged ${result.removed.length} .mtime sidecar(s) from local primary` + (options?.dryRun ? " (dry run)" : ""),
|
|
2565
2657
|
result.removed
|
|
2566
2658
|
);
|
|
2567
2659
|
}
|
|
2568
2660
|
if (result.failed.length > 0) {
|
|
2569
|
-
|
|
2661
|
+
log3.warn(`[ConfigRepo] failed to purge ${result.failed.length} .mtime sidecar(s):`, result.failed);
|
|
2570
2662
|
}
|
|
2571
2663
|
return result;
|
|
2572
2664
|
}
|
|
@@ -2586,13 +2678,13 @@ var ConfigRepo = class {
|
|
|
2586
2678
|
this.assertNotDisposed();
|
|
2587
2679
|
const result = await purgeKeepFiles(this.cachedFS, options);
|
|
2588
2680
|
if (result.removed.length > 0) {
|
|
2589
|
-
|
|
2681
|
+
log3.log(
|
|
2590
2682
|
`[ConfigRepo] purged ${result.removed.length} .keep placeholder(s) from local primary` + (options?.dryRun ? " (dry run)" : ""),
|
|
2591
2683
|
result.removed
|
|
2592
2684
|
);
|
|
2593
2685
|
}
|
|
2594
2686
|
if (result.failed.length > 0) {
|
|
2595
|
-
|
|
2687
|
+
log3.warn(`[ConfigRepo] failed to purge ${result.failed.length} .keep placeholder(s):`, result.failed);
|
|
2596
2688
|
}
|
|
2597
2689
|
return result;
|
|
2598
2690
|
}
|
|
@@ -2611,24 +2703,24 @@ var ConfigRepo = class {
|
|
|
2611
2703
|
}));
|
|
2612
2704
|
const result = await migrateVersionSidecars(this.cachedFS, { replicas });
|
|
2613
2705
|
if (result.renamed.length > 0) {
|
|
2614
|
-
|
|
2706
|
+
log3.log(
|
|
2615
2707
|
`[ConfigRepo] migrated ${result.renamed.length} legacy version sidecar(s) to new naming`,
|
|
2616
2708
|
result.renamed
|
|
2617
2709
|
);
|
|
2618
2710
|
}
|
|
2619
2711
|
if (result.deleted.length > 0) {
|
|
2620
|
-
|
|
2712
|
+
log3.log(
|
|
2621
2713
|
`[ConfigRepo] removed ${result.deleted.length} orphaned legacy version sidecar(s)`,
|
|
2622
2714
|
result.deleted
|
|
2623
2715
|
);
|
|
2624
2716
|
}
|
|
2625
2717
|
if (result.remoteDeleted.length > 0) {
|
|
2626
|
-
|
|
2718
|
+
log3.log(
|
|
2627
2719
|
`[ConfigRepo] removed ${result.remoteDeleted.length} remote residual legacy version sidecar(s)`
|
|
2628
2720
|
);
|
|
2629
2721
|
}
|
|
2630
2722
|
if (result.failed.length > 0) {
|
|
2631
|
-
|
|
2723
|
+
log3.warn(`[ConfigRepo] failed to migrate ${result.failed.length} legacy version sidecar(s):`, result.failed);
|
|
2632
2724
|
}
|
|
2633
2725
|
return result;
|
|
2634
2726
|
}
|
|
@@ -2651,9 +2743,9 @@ var ConfigRepo = class {
|
|
|
2651
2743
|
*/
|
|
2652
2744
|
startBackgroundSync() {
|
|
2653
2745
|
this.initialSyncPromise = this.initialSyncAndDedup().then(() => {
|
|
2654
|
-
|
|
2746
|
+
log3.log("[ConfigRepo] Background initial sync complete");
|
|
2655
2747
|
}).catch((err) => {
|
|
2656
|
-
|
|
2748
|
+
log3.error("[ConfigRepo] Background initial sync failed:", err);
|
|
2657
2749
|
}).finally(() => {
|
|
2658
2750
|
this.initialSyncPromise = null;
|
|
2659
2751
|
});
|
|
@@ -2687,7 +2779,7 @@ var ConfigRepo = class {
|
|
|
2687
2779
|
}
|
|
2688
2780
|
}
|
|
2689
2781
|
}
|
|
2690
|
-
|
|
2782
|
+
log3.log(`[ConfigRepo] updateTombstoneConfirmations: ${modified} tombstone(s) updated`);
|
|
2691
2783
|
if (modified > 0) this.invalidateTombstoneCache();
|
|
2692
2784
|
}
|
|
2693
2785
|
/**
|
|
@@ -2719,7 +2811,7 @@ var ConfigRepo = class {
|
|
|
2719
2811
|
}
|
|
2720
2812
|
}
|
|
2721
2813
|
}
|
|
2722
|
-
|
|
2814
|
+
log3.log(`[ConfigRepo] gcTombstones: removed ${tombstonePath} (all ${allBackendIds.length} backends confirmed)`);
|
|
2723
2815
|
}
|
|
2724
2816
|
}
|
|
2725
2817
|
}
|
|
@@ -2736,7 +2828,7 @@ var ConfigRepo = class {
|
|
|
2736
2828
|
this.assertNotDisposed();
|
|
2737
2829
|
const results = await this.flush();
|
|
2738
2830
|
for (const result of results) {
|
|
2739
|
-
|
|
2831
|
+
log3.log(
|
|
2740
2832
|
`[ConfigRepo] syncMetaToReplicas: ${result.pairId} +${result.filesCreated}/~${result.filesUpdated}/-${result.filesDeleted} skip:${result.filesSkipped} ${result.durationMs}ms`
|
|
2741
2833
|
);
|
|
2742
2834
|
}
|
|
@@ -2909,21 +3001,21 @@ var ConfigRepo = class {
|
|
|
2909
3001
|
// Internal — Setup
|
|
2910
3002
|
// -----------------------------------------------------------------------
|
|
2911
3003
|
async setupSync(backends, primaryBackendId, pollIntervalMs) {
|
|
2912
|
-
|
|
3004
|
+
log3.log(`[ConfigRepo] setupSync: ${backends.length} backends, primary=${primaryBackendId} pollInterval=${pollIntervalMs ?? "default"}ms`);
|
|
2913
3005
|
for (const desc of backends) {
|
|
2914
3006
|
if (desc.id === primaryBackendId) continue;
|
|
2915
3007
|
if (desc.enabled === false) {
|
|
2916
|
-
|
|
3008
|
+
log3.log(`[ConfigRepo] Skipping disabled replica: ${desc.id}`);
|
|
2917
3009
|
continue;
|
|
2918
3010
|
}
|
|
2919
|
-
|
|
3011
|
+
log3.log(`[ConfigRepo] Creating replica backend: id=${desc.id}, type=${desc.type}`);
|
|
2920
3012
|
try {
|
|
2921
3013
|
const instance = await createBackend(desc);
|
|
2922
3014
|
let fsInstance = instance;
|
|
2923
3015
|
if (this.cacheOptions) {
|
|
2924
3016
|
const { wrapWithCache: wrapWithCache2 } = await Promise.resolve().then(() => (init_cache_wrapper(), cache_wrapper_exports));
|
|
2925
3017
|
fsInstance = wrapWithCache2(instance, desc.id, this.cacheOptions);
|
|
2926
|
-
|
|
3018
|
+
log3.log(`[ConfigRepo] Replica ${desc.id} wrapped with CachedFileSystem (store=${this.cacheOptions.storeType ?? "IdbCacheStore"})`);
|
|
2927
3019
|
}
|
|
2928
3020
|
const syncable = backendToSyncableFS(fsInstance, `${desc.type}(${desc.id})`);
|
|
2929
3021
|
const pair = this.syncEngine.addPair(
|
|
@@ -2938,7 +3030,7 @@ var ConfigRepo = class {
|
|
|
2938
3030
|
this.invalidateTombstoneCache();
|
|
2939
3031
|
await this.processTombstones();
|
|
2940
3032
|
} catch (err) {
|
|
2941
|
-
|
|
3033
|
+
log3.warn("[ConfigRepo] preSyncHook processTombstones failed:", err);
|
|
2942
3034
|
}
|
|
2943
3035
|
},
|
|
2944
3036
|
postSyncHook: async () => {
|
|
@@ -2947,7 +3039,7 @@ var ConfigRepo = class {
|
|
|
2947
3039
|
await this.processTombstones();
|
|
2948
3040
|
await this.updateTombstoneConfirmations();
|
|
2949
3041
|
} catch (err) {
|
|
2950
|
-
|
|
3042
|
+
log3.warn("[ConfigRepo] postSyncHook tombstone processing failed:", err);
|
|
2951
3043
|
}
|
|
2952
3044
|
}
|
|
2953
3045
|
},
|
|
@@ -2960,9 +3052,9 @@ var ConfigRepo = class {
|
|
|
2960
3052
|
};
|
|
2961
3053
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
2962
3054
|
this.trackSyncErrors(desc.id, pair.pairId);
|
|
2963
|
-
|
|
3055
|
+
log3.log(`[ConfigRepo] Replica ${desc.id} created, sync pair=${pair.pairId}`);
|
|
2964
3056
|
} catch (err) {
|
|
2965
|
-
|
|
3057
|
+
log3.error(`[ConfigRepo] Failed to create replica ${desc.id} (${desc.type}):`, err);
|
|
2966
3058
|
this.backendStates.set(desc.id, {
|
|
2967
3059
|
backendId: desc.id,
|
|
2968
3060
|
error: {
|
|
@@ -2972,8 +3064,8 @@ var ConfigRepo = class {
|
|
|
2972
3064
|
});
|
|
2973
3065
|
}
|
|
2974
3066
|
}
|
|
2975
|
-
|
|
2976
|
-
|
|
3067
|
+
log3.log(`[ConfigRepo] setupSync complete. Replicas:`, Array.from(this.replicaBackends.keys()));
|
|
3068
|
+
log3.log(`[ConfigRepo] Sync statuses:`, this.getSyncStatuses());
|
|
2977
3069
|
}
|
|
2978
3070
|
// -----------------------------------------------------------------------
|
|
2979
3071
|
// Internal — Persistence
|
|
@@ -2985,12 +3077,12 @@ var ConfigRepo = class {
|
|
|
2985
3077
|
try {
|
|
2986
3078
|
const existing = await readVersion(this.fullFS, vPath);
|
|
2987
3079
|
if (existing && existing.hash === version.hash) {
|
|
2988
|
-
|
|
3080
|
+
log3.log("[ConfigRepo] skip version sidecar (hash unchanged):", vPath);
|
|
2989
3081
|
return;
|
|
2990
3082
|
}
|
|
2991
3083
|
} catch {
|
|
2992
3084
|
}
|
|
2993
|
-
|
|
3085
|
+
log3.log("[ConfigRepo] write version sidecar:", vPath, "v" + version.version);
|
|
2994
3086
|
await this.ensureDir(vPath);
|
|
2995
3087
|
await writeVersion(this.fullFS, vPath, version);
|
|
2996
3088
|
}
|
|
@@ -3094,7 +3186,7 @@ var ConfigRepo = class {
|
|
|
3094
3186
|
await this.resolveConflict(`${conflictId}/meta.json`, customMerge);
|
|
3095
3187
|
}
|
|
3096
3188
|
} catch (err) {
|
|
3097
|
-
|
|
3189
|
+
log3.error("[zen-fs-config] Conflict handler error:", err);
|
|
3098
3190
|
}
|
|
3099
3191
|
}
|
|
3100
3192
|
}
|
|
@@ -3206,11 +3298,11 @@ var ConfigRepo = class {
|
|
|
3206
3298
|
}
|
|
3207
3299
|
return { kind: "ok", desc, mtime };
|
|
3208
3300
|
} else {
|
|
3209
|
-
|
|
3301
|
+
log3.warn(`[ConfigRepo] Backend descriptor ${entry} is missing id/type fields, marking for cleanup`);
|
|
3210
3302
|
return { kind: "corrupt", filePath };
|
|
3211
3303
|
}
|
|
3212
3304
|
} catch (parseErr) {
|
|
3213
|
-
|
|
3305
|
+
log3.warn(`[ConfigRepo] Backend descriptor ${entry} has corrupted JSON: ${parseErr}. Marking for cleanup.`);
|
|
3214
3306
|
return { kind: "corrupt", filePath };
|
|
3215
3307
|
}
|
|
3216
3308
|
})
|
|
@@ -3281,7 +3373,7 @@ var ConfigRepo = class {
|
|
|
3281
3373
|
}
|
|
3282
3374
|
}
|
|
3283
3375
|
if (duplicates.length > 0) {
|
|
3284
|
-
|
|
3376
|
+
log3.log(
|
|
3285
3377
|
`[ConfigRepo] readAllBackendDescriptors: removing ${duplicates.length} duplicate(s): ${duplicates.join(", ")}`
|
|
3286
3378
|
);
|
|
3287
3379
|
for (const dupId of duplicates) {
|
|
@@ -3412,7 +3504,7 @@ var ConfigRepo = class {
|
|
|
3412
3504
|
* Shared by addBackend() and replaceBackend().
|
|
3413
3505
|
*/
|
|
3414
3506
|
async setupReplica(id, type, options, description) {
|
|
3415
|
-
|
|
3507
|
+
log3.log(`[ConfigRepo] addBackend: creating ${id} (${type})...`);
|
|
3416
3508
|
const instance = await createBackend({ type, options });
|
|
3417
3509
|
const syncable = backendToSyncableFS(instance, `${type}(${id})`);
|
|
3418
3510
|
const desc = { id, type, options, description };
|
|
@@ -3428,7 +3520,7 @@ var ConfigRepo = class {
|
|
|
3428
3520
|
this.invalidateTombstoneCache();
|
|
3429
3521
|
await this.processTombstones();
|
|
3430
3522
|
} catch (err) {
|
|
3431
|
-
|
|
3523
|
+
log3.warn("[ConfigRepo] preSyncHook processTombstones failed:", err);
|
|
3432
3524
|
}
|
|
3433
3525
|
},
|
|
3434
3526
|
postSyncHook: async () => {
|
|
@@ -3437,7 +3529,7 @@ var ConfigRepo = class {
|
|
|
3437
3529
|
await this.processTombstones();
|
|
3438
3530
|
await this.updateTombstoneConfirmations();
|
|
3439
3531
|
} catch (err) {
|
|
3440
|
-
|
|
3532
|
+
log3.warn("[ConfigRepo] postSyncHook tombstone processing failed:", err);
|
|
3441
3533
|
}
|
|
3442
3534
|
}
|
|
3443
3535
|
},
|
|
@@ -3450,7 +3542,7 @@ var ConfigRepo = class {
|
|
|
3450
3542
|
};
|
|
3451
3543
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
3452
3544
|
this.trackSyncErrors(id, pair.pairId);
|
|
3453
|
-
|
|
3545
|
+
log3.log(`[ConfigRepo] addBackend: ${id} (${type}) added, sync pair=${pair.pairId}`);
|
|
3454
3546
|
await this.syncMetaToReplicas();
|
|
3455
3547
|
this.syncEngine.watch(pair.pairId);
|
|
3456
3548
|
return pair.pairId;
|
|
@@ -3476,13 +3568,13 @@ var ConfigRepo = class {
|
|
|
3476
3568
|
}
|
|
3477
3569
|
}
|
|
3478
3570
|
this.syncEngine.removePair(replica.pairId);
|
|
3479
|
-
|
|
3571
|
+
log3.log(`[ConfigRepo] removeBackend: sync pair ${replica.pairId} removed`);
|
|
3480
3572
|
this.replicaBackends.delete(id);
|
|
3481
3573
|
if (replica.instance?.dispose) {
|
|
3482
3574
|
await replica.instance.dispose();
|
|
3483
3575
|
}
|
|
3484
3576
|
} else {
|
|
3485
|
-
|
|
3577
|
+
log3.log(`[ConfigRepo] removeBackend: "${id}" not in replicaBackends, cleaning up descriptor only`);
|
|
3486
3578
|
for (const descPath of descPaths) {
|
|
3487
3579
|
try {
|
|
3488
3580
|
await this.deleteFile(descPath);
|
|
@@ -3493,7 +3585,7 @@ var ConfigRepo = class {
|
|
|
3493
3585
|
}
|
|
3494
3586
|
this.backendStates.delete(id);
|
|
3495
3587
|
this.schedulePostDeleteSync();
|
|
3496
|
-
|
|
3588
|
+
log3.log(`[ConfigRepo] removeBackend: ${id} removed (tombstone written, remote cleaned)`);
|
|
3497
3589
|
}
|
|
3498
3590
|
/**
|
|
3499
3591
|
* Replace a config-sync backend's parameters in place (same id).
|
|
@@ -3540,11 +3632,11 @@ var ConfigRepo = class {
|
|
|
3540
3632
|
await this.setupReplica(id, type, options, description ?? before.description);
|
|
3541
3633
|
} catch (err) {
|
|
3542
3634
|
const reason = err instanceof Error ? err.message : String(err);
|
|
3543
|
-
|
|
3635
|
+
log3.warn(`[ConfigRepo] replaceBackend: "${id}" failed, rolling back old options:`, err);
|
|
3544
3636
|
try {
|
|
3545
3637
|
await this.setupReplica(id, before.type, before.options, before.description);
|
|
3546
3638
|
} catch (rollbackErr) {
|
|
3547
|
-
|
|
3639
|
+
log3.error(`[ConfigRepo] replaceBackend: rollback for "${id}" ALSO failed:`, rollbackErr);
|
|
3548
3640
|
}
|
|
3549
3641
|
throw new Error(`\u66F4\u65B0\u540E\u7AEF\u53C2\u6570\u5931\u8D25\uFF1A${reason}\uFF08\u5DF2\u5C1D\u8BD5\u56DE\u6EDA\u65E7\u53C2\u6570\uFF09`);
|
|
3550
3642
|
}
|
|
@@ -3560,7 +3652,7 @@ var ConfigRepo = class {
|
|
|
3560
3652
|
const existing = await this.cachedFS.readFile(path, "utf-8");
|
|
3561
3653
|
const current = existing.trim();
|
|
3562
3654
|
if (current && current !== type) {
|
|
3563
|
-
|
|
3655
|
+
log3.warn(`[ConfigRepo] group-type already set to "${current}" at ${path}, ignoring request to set "${type}"`);
|
|
3564
3656
|
return;
|
|
3565
3657
|
}
|
|
3566
3658
|
} catch {
|
|
@@ -3591,7 +3683,7 @@ var ConfigRepo = class {
|
|
|
3591
3683
|
features: existingDescriptor.features ?? CONFIG_GROUP_FEATURES
|
|
3592
3684
|
});
|
|
3593
3685
|
}
|
|
3594
|
-
|
|
3686
|
+
log3.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
3595
3687
|
}
|
|
3596
3688
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
3597
3689
|
async getGroupType() {
|
|
@@ -3686,7 +3778,7 @@ var ConfigRepo = class {
|
|
|
3686
3778
|
if (this.appDataGroups.has(id)) {
|
|
3687
3779
|
throw new Error(`App data group "${id}" already exists. Use removeAppDataGroup() first.`);
|
|
3688
3780
|
}
|
|
3689
|
-
|
|
3781
|
+
log3.log(`[ConfigRepo] createAppDataGroup: creating "${id}" with ${backends.length} backend(s)`);
|
|
3690
3782
|
const resolvedBackends = [];
|
|
3691
3783
|
for (const desc of backends) {
|
|
3692
3784
|
assertValidBackendId(desc.id);
|
|
@@ -3713,7 +3805,7 @@ var ConfigRepo = class {
|
|
|
3713
3805
|
};
|
|
3714
3806
|
await this.writeAppDataGroupDescriptorFile(id, descriptor);
|
|
3715
3807
|
this.appDataGroups.set(id, group);
|
|
3716
|
-
|
|
3808
|
+
log3.log(`[ConfigRepo] createAppDataGroup: "${id}" created`);
|
|
3717
3809
|
return group;
|
|
3718
3810
|
}
|
|
3719
3811
|
/**
|
|
@@ -3756,7 +3848,7 @@ var ConfigRepo = class {
|
|
|
3756
3848
|
try {
|
|
3757
3849
|
await live.writeOwnGroupDescriptor();
|
|
3758
3850
|
} catch (err) {
|
|
3759
|
-
|
|
3851
|
+
log3.warn(`[ConfigRepo] updateAppDataGroupName: "${id}" group.json update failed:`, err);
|
|
3760
3852
|
}
|
|
3761
3853
|
}
|
|
3762
3854
|
const descriptor = {
|
|
@@ -3819,7 +3911,7 @@ var ConfigRepo = class {
|
|
|
3819
3911
|
return group;
|
|
3820
3912
|
} catch (err) {
|
|
3821
3913
|
const reason = err instanceof Error ? err.message : String(err);
|
|
3822
|
-
|
|
3914
|
+
log3.warn(`[ConfigRepo] replaceAppDataGroupBackend: "${backendId}" failed, rolling back:`, err);
|
|
3823
3915
|
try {
|
|
3824
3916
|
const restored = new AppDataGroupImpl(
|
|
3825
3917
|
groupId,
|
|
@@ -3833,7 +3925,7 @@ var ConfigRepo = class {
|
|
|
3833
3925
|
await this.updateAppDataGroupDescriptor(groupId, restored.listDeclaredBackends());
|
|
3834
3926
|
this.appDataGroups.set(groupId, restored);
|
|
3835
3927
|
} catch (rollbackErr) {
|
|
3836
|
-
|
|
3928
|
+
log3.error("[ConfigRepo] replaceAppDataGroupBackend: rollback ALSO failed:", rollbackErr);
|
|
3837
3929
|
}
|
|
3838
3930
|
throw new Error(`\u66F4\u65B0\u540E\u7AEF\u53C2\u6570\u5931\u8D25\uFF1A${reason}\uFF08\u5DF2\u5C1D\u8BD5\u56DE\u6EDA\u65E7\u53C2\u6570\uFF09`);
|
|
3839
3931
|
}
|
|
@@ -3951,7 +4043,7 @@ var ConfigRepo = class {
|
|
|
3951
4043
|
try {
|
|
3952
4044
|
await this.deleteFile(descPath);
|
|
3953
4045
|
} catch (err) {
|
|
3954
|
-
|
|
4046
|
+
log3.log(`[ConfigRepo] removeAppDataGroup: deleteFile failed for "${id}" at ${descPath}:`, err);
|
|
3955
4047
|
try {
|
|
3956
4048
|
await this.cachedFS.unlink(descPath);
|
|
3957
4049
|
} catch {
|
|
@@ -3959,7 +4051,7 @@ var ConfigRepo = class {
|
|
|
3959
4051
|
await this.unlinkVersionSidecar(this.cachedFS, descPath);
|
|
3960
4052
|
}
|
|
3961
4053
|
}
|
|
3962
|
-
|
|
4054
|
+
log3.log(`[ConfigRepo] removeAppDataGroup: "${id}" removed`);
|
|
3963
4055
|
}
|
|
3964
4056
|
async listAccountBackends() {
|
|
3965
4057
|
this.assertNotDisposed();
|
|
@@ -4134,24 +4226,24 @@ var AppDataGroupImpl = class {
|
|
|
4134
4226
|
try {
|
|
4135
4227
|
const purged = await purgeMtimeSidecars(this.localFS);
|
|
4136
4228
|
if (purged.removed.length > 0) {
|
|
4137
|
-
|
|
4229
|
+
log3.warn(
|
|
4138
4230
|
`[AppDataGroup:${this.groupId}] purged ${purged.removed.length} leaked .mtime sidecar(s):`,
|
|
4139
4231
|
purged.removed
|
|
4140
4232
|
);
|
|
4141
4233
|
}
|
|
4142
4234
|
} catch (err) {
|
|
4143
|
-
|
|
4235
|
+
log3.warn(`[AppDataGroup:${this.groupId}] .mtime purge failed:`, err?.message ?? err);
|
|
4144
4236
|
}
|
|
4145
4237
|
try {
|
|
4146
4238
|
const purgedKeep = await purgeKeepFiles(this.localFS);
|
|
4147
4239
|
if (purgedKeep.removed.length > 0) {
|
|
4148
|
-
|
|
4240
|
+
log3.warn(
|
|
4149
4241
|
`[AppDataGroup:${this.groupId}] purged ${purgedKeep.removed.length} leaked .keep placeholder(s):`,
|
|
4150
4242
|
purgedKeep.removed
|
|
4151
4243
|
);
|
|
4152
4244
|
}
|
|
4153
4245
|
} catch (err) {
|
|
4154
|
-
|
|
4246
|
+
log3.warn(`[AppDataGroup:${this.groupId}] .keep purge failed:`, err?.message ?? err);
|
|
4155
4247
|
}
|
|
4156
4248
|
const localSyncable = backendToSyncableFS(this.localFS, `local(${this.groupId})`);
|
|
4157
4249
|
this.tombstones = new TombstoneStore(this.localFS, this.localBackendId);
|
|
@@ -4161,13 +4253,13 @@ var AppDataGroupImpl = class {
|
|
|
4161
4253
|
try {
|
|
4162
4254
|
backendsChanged = await this.loadBackendDescriptors();
|
|
4163
4255
|
} catch (err) {
|
|
4164
|
-
|
|
4256
|
+
log3.warn(`[AppDataGroup:${this.groupId}] failed to load .meta/backends:`, err);
|
|
4165
4257
|
this._backends = this._backends ?? [];
|
|
4166
4258
|
}
|
|
4167
4259
|
try {
|
|
4168
4260
|
await this.writeOwnGroupDescriptor();
|
|
4169
4261
|
} catch (err) {
|
|
4170
|
-
|
|
4262
|
+
log3.warn(`[AppDataGroup:${this.groupId}] failed to write .meta/group.json:`, err);
|
|
4171
4263
|
}
|
|
4172
4264
|
this.fs = createChrootFS(this.localFS, "/", {
|
|
4173
4265
|
hiddenPrefixes: [META_DIR, CONFIG_DIR],
|
|
@@ -4177,7 +4269,7 @@ var AppDataGroupImpl = class {
|
|
|
4177
4269
|
});
|
|
4178
4270
|
const { kept, removed } = dedupeAppDataBackends(this._backends);
|
|
4179
4271
|
if (removed.length > 0) {
|
|
4180
|
-
|
|
4272
|
+
log3.warn(
|
|
4181
4273
|
`[AppDataGroup:${this.groupId}] dedupe: removing ${removed.length} duplicate backend(s) (${removed.map((b) => b.id).join(", ")}) \u2014 keeping ${kept.map((b) => b.id).join(", ")}`
|
|
4182
4274
|
);
|
|
4183
4275
|
this._backends = kept;
|
|
@@ -4191,7 +4283,7 @@ var AppDataGroupImpl = class {
|
|
|
4191
4283
|
features: this._declaredFeatures
|
|
4192
4284
|
});
|
|
4193
4285
|
} catch (err) {
|
|
4194
|
-
|
|
4286
|
+
log3.warn(`[AppDataGroup:${this.groupId}] failed to persist backend topology:`, err);
|
|
4195
4287
|
}
|
|
4196
4288
|
}
|
|
4197
4289
|
for (const desc of this._backends) {
|
|
@@ -4223,26 +4315,26 @@ var AppDataGroupImpl = class {
|
|
|
4223
4315
|
if (this.features.conflicts) {
|
|
4224
4316
|
const conflictHandler = (event) => {
|
|
4225
4317
|
this.archiveConflict(event).catch((err) => {
|
|
4226
|
-
|
|
4318
|
+
log3.warn(`[AppDataGroup:${this.groupId}] conflict archive failed:`, err);
|
|
4227
4319
|
});
|
|
4228
4320
|
};
|
|
4229
4321
|
this.syncEngine.on(pair.pairId, "conflict", conflictHandler);
|
|
4230
4322
|
}
|
|
4231
4323
|
this.trackSyncErrors(desc.id, pair.pairId);
|
|
4232
|
-
|
|
4324
|
+
log3.log(`[AppDataGroup:${this.groupId}] backend ${desc.id} (${desc.type}) connected, pair=${pair.pairId}`);
|
|
4233
4325
|
} catch (err) {
|
|
4234
4326
|
const message = err instanceof Error ? err.message : String(err);
|
|
4235
4327
|
this.backendStates.set(desc.id, {
|
|
4236
4328
|
backendId: desc.id,
|
|
4237
4329
|
error: { message, timestamp: Date.now() }
|
|
4238
4330
|
});
|
|
4239
|
-
|
|
4331
|
+
log3.error(`[AppDataGroup:${this.groupId}] Failed to create backend ${desc.id} (${desc.type}):`, err);
|
|
4240
4332
|
}
|
|
4241
4333
|
}
|
|
4242
4334
|
try {
|
|
4243
4335
|
await this.syncEngine.syncAll();
|
|
4244
4336
|
} catch (err) {
|
|
4245
|
-
|
|
4337
|
+
log3.warn(`[AppDataGroup:${this.groupId}] Initial sync failed:`, err);
|
|
4246
4338
|
}
|
|
4247
4339
|
this.syncEngine.watchAll();
|
|
4248
4340
|
}
|
|
@@ -4257,7 +4349,7 @@ var AppDataGroupImpl = class {
|
|
|
4257
4349
|
try {
|
|
4258
4350
|
await this.tombstones.gc(this.allBackendIds(), this.tombstoneTargets());
|
|
4259
4351
|
} catch (err) {
|
|
4260
|
-
|
|
4352
|
+
log3.warn(`[AppDataGroup:${this.groupId}] tombstone GC failed:`, err);
|
|
4261
4353
|
}
|
|
4262
4354
|
return Array.from(results.values());
|
|
4263
4355
|
}
|
|
@@ -4292,7 +4384,7 @@ var AppDataGroupImpl = class {
|
|
|
4292
4384
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : toUint8Array2(data);
|
|
4293
4385
|
await this.versions.record(path, bytes);
|
|
4294
4386
|
} catch (err) {
|
|
4295
|
-
|
|
4387
|
+
log3.warn(`[AppDataGroup:${this.groupId}] version record failed for ${path}:`, err);
|
|
4296
4388
|
}
|
|
4297
4389
|
}
|
|
4298
4390
|
/** Delete tombstoned files on local + every connected backend before/after sync. */
|
|
@@ -4300,14 +4392,14 @@ var AppDataGroupImpl = class {
|
|
|
4300
4392
|
try {
|
|
4301
4393
|
await this.tombstones.process(this.tombstoneTargets());
|
|
4302
4394
|
} catch (err) {
|
|
4303
|
-
|
|
4395
|
+
log3.warn(`[AppDataGroup:${this.groupId}] ${stage} tombstone pass failed:`, err);
|
|
4304
4396
|
}
|
|
4305
4397
|
}
|
|
4306
4398
|
async confirmTombstones() {
|
|
4307
4399
|
try {
|
|
4308
4400
|
await this.tombstones.confirm(this.allBackendIds());
|
|
4309
4401
|
} catch (err) {
|
|
4310
|
-
|
|
4402
|
+
log3.warn(`[AppDataGroup:${this.groupId}] tombstone confirmations failed:`, err);
|
|
4311
4403
|
}
|
|
4312
4404
|
}
|
|
4313
4405
|
/** Write a tombstone for `filePath`. Records metadata only — it never creates the file. */
|
|
@@ -4340,7 +4432,7 @@ var AppDataGroupImpl = class {
|
|
|
4340
4432
|
}
|
|
4341
4433
|
await removeDirectoryTree(this.localFS, normalized);
|
|
4342
4434
|
this.schedulePostDeleteSync();
|
|
4343
|
-
|
|
4435
|
+
log3.log(`[AppDataGroup:${this.groupId}] deleteFile(directory): ${normalized} (${files.length} file(s))`);
|
|
4344
4436
|
return;
|
|
4345
4437
|
}
|
|
4346
4438
|
await this.writeTombstoneFor(normalized);
|
|
@@ -4379,7 +4471,7 @@ var AppDataGroupImpl = class {
|
|
|
4379
4471
|
try {
|
|
4380
4472
|
await this.syncEngine.syncAll();
|
|
4381
4473
|
} catch (err) {
|
|
4382
|
-
|
|
4474
|
+
log3.warn(`[AppDataGroup:${this.groupId}] sync after conflict resolve failed:`, err);
|
|
4383
4475
|
}
|
|
4384
4476
|
}
|
|
4385
4477
|
readConflictBackup(conflictId, fileType) {
|
|
@@ -4414,7 +4506,7 @@ var AppDataGroupImpl = class {
|
|
|
4414
4506
|
if (this.dataBackends.has(id)) {
|
|
4415
4507
|
throw new Error(`Backend "${id}" already exists in data group "${this.groupId}"`);
|
|
4416
4508
|
}
|
|
4417
|
-
|
|
4509
|
+
log3.log(`[AppDataGroup:${this.groupId}] addBackend: creating ${id} (${type})...`);
|
|
4418
4510
|
const instance = await createBackend({ type, options });
|
|
4419
4511
|
const syncable = backendToSyncableFS(instance, `${type}(${id})`);
|
|
4420
4512
|
const localSyncable = backendToSyncableFS(this.localFS, `local(${this.groupId})`);
|
|
@@ -4442,13 +4534,13 @@ var AppDataGroupImpl = class {
|
|
|
4442
4534
|
if (this.features.conflicts) {
|
|
4443
4535
|
this.syncEngine.on(pair.pairId, "conflict", (event) => {
|
|
4444
4536
|
this.archiveConflict(event).catch((err) => {
|
|
4445
|
-
|
|
4537
|
+
log3.warn(`[AppDataGroup:${this.groupId}] conflict archive failed:`, err);
|
|
4446
4538
|
});
|
|
4447
4539
|
});
|
|
4448
4540
|
}
|
|
4449
4541
|
this.trackSyncErrors(id, pair.pairId);
|
|
4450
4542
|
this._backends = [...this._backends.filter((b) => b.id !== id), desc];
|
|
4451
|
-
|
|
4543
|
+
log3.log(`[AppDataGroup:${this.groupId}] addBackend: ${id} (${type}) connected, pair=${pair.pairId}`);
|
|
4452
4544
|
try {
|
|
4453
4545
|
const stale = (await this.tombstones.list()).find(
|
|
4454
4546
|
(t) => t.path === backendMetaFilePath(id)
|
|
@@ -4456,12 +4548,12 @@ var AppDataGroupImpl = class {
|
|
|
4456
4548
|
if (stale) await this.tombstones.remove(stale);
|
|
4457
4549
|
await writeBackendMetaDescriptor(this.localFS, desc);
|
|
4458
4550
|
} catch (err) {
|
|
4459
|
-
|
|
4551
|
+
log3.warn(`[AppDataGroup:${this.groupId}] addBackend: failed to write .meta/backends/${id}.json:`, err);
|
|
4460
4552
|
}
|
|
4461
4553
|
try {
|
|
4462
4554
|
await this.syncEngine.sync(pair.pairId);
|
|
4463
4555
|
} catch (err) {
|
|
4464
|
-
|
|
4556
|
+
log3.warn(`[AppDataGroup:${this.groupId}] addBackend: initial sync failed for ${id}:`, err);
|
|
4465
4557
|
}
|
|
4466
4558
|
this.syncEngine.watch(pair.pairId);
|
|
4467
4559
|
await this.parent.updateAppDataGroupDescriptor(this.groupId, this._backends, {
|
|
@@ -4492,7 +4584,7 @@ var AppDataGroupImpl = class {
|
|
|
4492
4584
|
if (backend?.instance?.dispose) {
|
|
4493
4585
|
await backend.instance.dispose();
|
|
4494
4586
|
}
|
|
4495
|
-
|
|
4587
|
+
log3.log(`[AppDataGroup:${this.groupId}] removeBackend: ${id} removed`);
|
|
4496
4588
|
}
|
|
4497
4589
|
listBackends() {
|
|
4498
4590
|
return Array.from(this.dataBackends.values()).map((b) => b.desc);
|
|
@@ -4534,44 +4626,44 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4534
4626
|
idbStoreName: options.idbStoreName,
|
|
4535
4627
|
folderPath: options.folderPath
|
|
4536
4628
|
});
|
|
4537
|
-
|
|
4629
|
+
log3.log(`[createConfigRepo] Creating local primary (type: ${localPrimary.type})...`);
|
|
4538
4630
|
const primaryInstance = await createBackend(localPrimary);
|
|
4539
4631
|
const cachedFS = primaryInstance;
|
|
4540
4632
|
if (options.purgeMtimeSidecars !== false) {
|
|
4541
4633
|
try {
|
|
4542
4634
|
const purged = await purgeMtimeSidecars(cachedFS);
|
|
4543
4635
|
if (purged.removed.length > 0) {
|
|
4544
|
-
|
|
4636
|
+
log3.warn(
|
|
4545
4637
|
`[createConfigRepo] purged ${purged.removed.length} leaked .mtime sidecar(s) from local primary:`,
|
|
4546
4638
|
purged.removed
|
|
4547
4639
|
);
|
|
4548
4640
|
}
|
|
4549
4641
|
} catch (err) {
|
|
4550
|
-
|
|
4642
|
+
log3.warn(`[createConfigRepo] .mtime purge failed:`, err?.message ?? err);
|
|
4551
4643
|
}
|
|
4552
4644
|
}
|
|
4553
4645
|
if (options.purgeKeepFiles !== false) {
|
|
4554
4646
|
try {
|
|
4555
4647
|
const purged = await purgeKeepFiles(cachedFS);
|
|
4556
4648
|
if (purged.removed.length > 0) {
|
|
4557
|
-
|
|
4649
|
+
log3.warn(
|
|
4558
4650
|
`[createConfigRepo] purged ${purged.removed.length} leaked .keep placeholder(s) from local primary:`,
|
|
4559
4651
|
purged.removed
|
|
4560
4652
|
);
|
|
4561
4653
|
}
|
|
4562
4654
|
} catch (err) {
|
|
4563
|
-
|
|
4655
|
+
log3.warn(`[createConfigRepo] .keep purge failed:`, err?.message ?? err);
|
|
4564
4656
|
}
|
|
4565
4657
|
}
|
|
4566
4658
|
const cacheOptions = options.cache === false ? void 0 : options.cache ?? {};
|
|
4567
4659
|
try {
|
|
4568
4660
|
await primaryInstance.mkdir(META_DIR);
|
|
4569
|
-
|
|
4661
|
+
log3.log(`[createConfigRepo] /.meta/ ready`);
|
|
4570
4662
|
} catch (err) {
|
|
4571
4663
|
const msg = err.message || "";
|
|
4572
4664
|
if (msg.includes("File exists") || msg.includes("EEXIST") || err.code === "EEXIST") {
|
|
4573
4665
|
} else {
|
|
4574
|
-
|
|
4666
|
+
log3.error(`[createConfigRepo] Failed to ensure /.meta/:`, err.message);
|
|
4575
4667
|
}
|
|
4576
4668
|
}
|
|
4577
4669
|
try {
|
|
@@ -4582,7 +4674,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4582
4674
|
} catch {
|
|
4583
4675
|
await ensureParentDir2(primaryInstance, path);
|
|
4584
4676
|
await primaryInstance.writeFile(path, groupTypeBytes);
|
|
4585
|
-
|
|
4677
|
+
log3.log(`[createConfigRepo] group-type set to "config-sync" at ${path}`);
|
|
4586
4678
|
}
|
|
4587
4679
|
}
|
|
4588
4680
|
if (!await readGroupDescriptor(primaryInstance)) {
|
|
@@ -4594,7 +4686,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4594
4686
|
});
|
|
4595
4687
|
}
|
|
4596
4688
|
} catch (err) {
|
|
4597
|
-
|
|
4689
|
+
log3.warn(`[createConfigRepo] Failed to write group metadata:`, err.message);
|
|
4598
4690
|
}
|
|
4599
4691
|
const tempRepo = new ConfigRepo(
|
|
4600
4692
|
appId,
|
|
@@ -4608,11 +4700,11 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4608
4700
|
);
|
|
4609
4701
|
const oldBackendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
|
|
4610
4702
|
if (oldBackendsMeta && oldBackendsMeta.backends?.length > 0) {
|
|
4611
|
-
|
|
4703
|
+
log3.log(`[createConfigRepo] Migrating ${oldBackendsMeta.backends.length} backend(s) from backends.json to individual files...`);
|
|
4612
4704
|
await tempRepo.ensureDir(`${BACKENDS_DIR}/.keep`);
|
|
4613
4705
|
for (const desc of oldBackendsMeta.backends) {
|
|
4614
4706
|
if (desc.id === LOCAL_IDB_BACKEND_ID) {
|
|
4615
|
-
|
|
4707
|
+
log3.log(`[createConfigRepo] Skipping local backend ${desc.id} during migration`);
|
|
4616
4708
|
continue;
|
|
4617
4709
|
}
|
|
4618
4710
|
await tempRepo.writeBackendDescriptor(desc);
|
|
@@ -4630,7 +4722,7 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4630
4722
|
}
|
|
4631
4723
|
}
|
|
4632
4724
|
}
|
|
4633
|
-
|
|
4725
|
+
log3.log(`[createConfigRepo] Migration complete`);
|
|
4634
4726
|
}
|
|
4635
4727
|
let allBackends = await tempRepo.readAllBackendDescriptors();
|
|
4636
4728
|
if (options.backendInfo) {
|
|
@@ -4648,19 +4740,19 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4648
4740
|
type: options.backendInfo.type,
|
|
4649
4741
|
options: options.backendInfo.options
|
|
4650
4742
|
});
|
|
4651
|
-
|
|
4743
|
+
log3.log(`[createConfigRepo] Added replica backend: ${replicaId} (${options.backendInfo.type})`);
|
|
4652
4744
|
allBackends = [...allBackends, { id: replicaId, type: options.backendInfo.type, options: options.backendInfo.options }];
|
|
4653
4745
|
} else if (dupConfig) {
|
|
4654
|
-
|
|
4746
|
+
log3.log(`[createConfigRepo] Replica with same config already registered as "${dupConfig.id}", skipping`);
|
|
4655
4747
|
} else {
|
|
4656
|
-
|
|
4748
|
+
log3.log(`[createConfigRepo] Replica ${replicaId} already registered`);
|
|
4657
4749
|
}
|
|
4658
4750
|
}
|
|
4659
|
-
|
|
4751
|
+
log3.log(`[createConfigRepo] Replica backends: ${allBackends.map((b) => b.id).join(", ") || "(none)"}`);
|
|
4660
4752
|
let nodeId = options.nodeId;
|
|
4661
4753
|
if (!nodeId) {
|
|
4662
4754
|
nodeId = `node-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
4663
|
-
|
|
4755
|
+
log3.log(`[createConfigRepo] Generated nodeId: ${nodeId}`);
|
|
4664
4756
|
}
|
|
4665
4757
|
const serializer = createSerializerChain(options.serializer);
|
|
4666
4758
|
const repo = new ConfigRepo(
|
|
@@ -4683,30 +4775,30 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
4683
4775
|
try {
|
|
4684
4776
|
const mig = await repo.migrateLegacyVersionSidecars();
|
|
4685
4777
|
if (mig.renamed.length === 0 && mig.deleted.length === 0 && mig.remoteDeleted.length === 0) {
|
|
4686
|
-
|
|
4778
|
+
log3.log("[createConfigRepo] no legacy version sidecars to migrate");
|
|
4687
4779
|
}
|
|
4688
4780
|
} catch (err) {
|
|
4689
|
-
|
|
4781
|
+
log3.warn(`[createConfigRepo] version sidecar migration failed:`, err?.message ?? err);
|
|
4690
4782
|
}
|
|
4691
4783
|
}
|
|
4692
4784
|
await repo.load();
|
|
4693
4785
|
if (repo.replicaCount > 0) {
|
|
4694
|
-
|
|
4786
|
+
log3.log("[createConfigRepo] Starting background initial sync + dedup...");
|
|
4695
4787
|
repo.startBackgroundSync();
|
|
4696
4788
|
}
|
|
4697
4789
|
repo.syncMetaToReplicas().catch((err) => {
|
|
4698
|
-
|
|
4790
|
+
log3.error("[createConfigRepo] background syncMetaToReplicas failed:", err);
|
|
4699
4791
|
});
|
|
4700
4792
|
return repo;
|
|
4701
4793
|
}
|
|
4702
4794
|
|
|
4703
4795
|
// src/connect.ts
|
|
4704
4796
|
init_backend_registry();
|
|
4705
|
-
var
|
|
4797
|
+
var log4 = createLogger("connect");
|
|
4706
4798
|
var GROUP_TYPE_FILE2 = "/.config/group-type";
|
|
4707
4799
|
var LEGACY_GROUP_TYPE_FILE2 = "/.meta/group-type";
|
|
4708
4800
|
async function detectGroupType(type, options) {
|
|
4709
|
-
|
|
4801
|
+
log4(`detectGroupType: connecting to ${type}...`);
|
|
4710
4802
|
const tempBackend = await createBackend({ type, options });
|
|
4711
4803
|
try {
|
|
4712
4804
|
for (const path of [GROUP_TYPE_FILE2, LEGACY_GROUP_TYPE_FILE2]) {
|
|
@@ -4714,15 +4806,15 @@ async function detectGroupType(type, options) {
|
|
|
4714
4806
|
const raw = await tempBackend.readFile(path, "utf-8");
|
|
4715
4807
|
const groupType = raw.trim();
|
|
4716
4808
|
if (groupType === "config-sync" || groupType === "data-sync") {
|
|
4717
|
-
|
|
4809
|
+
log4(`detectGroupType: detected "${groupType}" at ${path}`);
|
|
4718
4810
|
return groupType;
|
|
4719
4811
|
}
|
|
4720
|
-
|
|
4812
|
+
log4(`detectGroupType: unknown group-type value "${groupType}" at ${path}, treating as null`);
|
|
4721
4813
|
return null;
|
|
4722
4814
|
} catch {
|
|
4723
4815
|
}
|
|
4724
4816
|
}
|
|
4725
|
-
|
|
4817
|
+
log4(`detectGroupType: no group-type file found (new backend)`);
|
|
4726
4818
|
return null;
|
|
4727
4819
|
} finally {
|
|
4728
4820
|
if (tempBackend?.dispose) {
|
|
@@ -4731,7 +4823,7 @@ async function detectGroupType(type, options) {
|
|
|
4731
4823
|
}
|
|
4732
4824
|
}
|
|
4733
4825
|
async function connect(appId, options = {}) {
|
|
4734
|
-
|
|
4826
|
+
log4(`connect: appId=${appId}`);
|
|
4735
4827
|
if (!options.backendInfo) {
|
|
4736
4828
|
const repo2 = await createConfigRepo(appId, {
|
|
4737
4829
|
idbStoreName: options.idbStoreName,
|
|
@@ -4749,7 +4841,7 @@ async function connect(appId, options = {}) {
|
|
|
4749
4841
|
try {
|
|
4750
4842
|
appDataGroups2.push(await repo2.getAppDataGroup(d.id));
|
|
4751
4843
|
} catch (err) {
|
|
4752
|
-
|
|
4844
|
+
log4(`connect: failed to load app data group "${d.id}":`, err);
|
|
4753
4845
|
}
|
|
4754
4846
|
}
|
|
4755
4847
|
let dataGroup2 = appDataGroups2[0];
|
|
@@ -4778,7 +4870,7 @@ async function connect(appId, options = {}) {
|
|
|
4778
4870
|
groupType = detectedType;
|
|
4779
4871
|
} else {
|
|
4780
4872
|
groupType = options.groupType ?? "config-sync";
|
|
4781
|
-
|
|
4873
|
+
log4(`connect: new backend, using groupType="${groupType}"`);
|
|
4782
4874
|
}
|
|
4783
4875
|
const repo = await createConfigRepo(
|
|
4784
4876
|
appId,
|
|
@@ -4807,7 +4899,7 @@ async function connect(appId, options = {}) {
|
|
|
4807
4899
|
try {
|
|
4808
4900
|
appDataGroups.push(await repo.getAppDataGroup(d.id));
|
|
4809
4901
|
} catch (err) {
|
|
4810
|
-
|
|
4902
|
+
log4(`connect: failed to load app data group "${d.id}":`, err);
|
|
4811
4903
|
}
|
|
4812
4904
|
}
|
|
4813
4905
|
let dataGroup = appDataGroups[0];
|