zen-fs-config 0.5.50 → 0.5.51

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 CHANGED
@@ -1515,6 +1515,9 @@ async function existsSafe(fs, path) {
1515
1515
  return false;
1516
1516
  }
1517
1517
  }
1518
+ function isMtimeSidecarPath(path) {
1519
+ return path.endsWith(".mtime");
1520
+ }
1518
1521
  function encodeMetaPath(filePath) {
1519
1522
  const normalized = filePath.startsWith("/") ? filePath : `/${filePath}`;
1520
1523
  return normalized.replace(/^\//, "").replace(/\//g, "__").replace(/\./g, "++");
@@ -1607,7 +1610,7 @@ var TombstoneStore = class {
1607
1610
  }
1608
1611
  }
1609
1612
  async deleteEverywhere(fs, filePath) {
1610
- if (!await existsSafe(fs, filePath)) return;
1613
+ if (!isMtimeSidecarPath(filePath) && !await existsSafe(fs, filePath)) return;
1611
1614
  try {
1612
1615
  await fs.unlink(filePath);
1613
1616
  } catch {
@@ -2191,7 +2194,9 @@ var ConfigRepo = class {
2191
2194
  const files = await collectFilesUnder(this.cachedFS, normalizedPath);
2192
2195
  for (const file of files) await this.deleteFile(file);
2193
2196
  for (const dir of await collectDirectoriesUnder(this.cachedFS, normalizedPath)) {
2194
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
2197
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
2198
+ await this.writeTombstoneFor(keepPath);
2199
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
2195
2200
  }
2196
2201
  await removeDirectoryTree(this.cachedFS, normalizedPath);
2197
2202
  this.invalidateTombstoneCache();
@@ -2211,6 +2216,12 @@ var ConfigRepo = class {
2211
2216
  } catch {
2212
2217
  }
2213
2218
  }
2219
+ if (!isMtimeSidecar(normalizedPath)) {
2220
+ try {
2221
+ await this.cachedFS.unlink(`${normalizedPath}.mtime`);
2222
+ } catch {
2223
+ }
2224
+ }
2214
2225
  log2.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePathFor(normalizedPath)})`);
2215
2226
  this.invalidateTombstoneCache();
2216
2227
  this.schedulePostDeleteSync();
@@ -2289,9 +2300,10 @@ var ConfigRepo = class {
2289
2300
  let processed = 0;
2290
2301
  let alreadyDeleted = 0;
2291
2302
  for (const tombstone of tombstones) {
2292
- const tVersionPath = versionPathFor(tombstone.path);
2293
- log2.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"}`);
2294
- const existedOnPrimary = await this.safeExists(this.cachedFS, tombstone.path);
2303
+ const forceDelete = isMtimeSidecar(tombstone.path);
2304
+ const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
2305
+ log2.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"} forceDelete=${forceDelete}`);
2306
+ const existedOnPrimary = forceDelete || await this.safeExists(this.cachedFS, tombstone.path);
2295
2307
  log2.log(`[TOMB-TRACE] primary safeExists(${tombstone.path}) \u2192 ${existedOnPrimary}`);
2296
2308
  if (existedOnPrimary) {
2297
2309
  log2.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on primary \u2192 EXISTS`);
@@ -2315,7 +2327,7 @@ var ConfigRepo = class {
2315
2327
  }
2316
2328
  for (const [replicaId, replica] of this.replicaBackends) {
2317
2329
  log2.log(`[TOMB-TRACE] checking replica: ${replicaId} for ${tombstone.path}`);
2318
- const existed = await this.safeExists(replica.instance, tombstone.path);
2330
+ const existed = forceDelete || await this.safeExists(replica.instance, tombstone.path);
2319
2331
  log2.log(`[TOMB-TRACE] replica ${replicaId} safeExists(${tombstone.path}) \u2192 ${existed}`);
2320
2332
  if (existed) {
2321
2333
  log2.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on ${replicaId} \u2192 EXISTS`);
@@ -3973,7 +3985,9 @@ var AppDataGroupImpl = class {
3973
3985
  const files = await collectFilesUnder(this.localFS, normalized);
3974
3986
  for (const file of files) await this.deleteFile(file);
3975
3987
  for (const dir of await collectDirectoriesUnder(this.localFS, normalized)) {
3976
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
3988
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
3989
+ await this.writeTombstoneFor(keepPath);
3990
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
3977
3991
  }
3978
3992
  await removeDirectoryTree(this.localFS, normalized);
3979
3993
  this.schedulePostDeleteSync();
@@ -3992,6 +4006,12 @@ var AppDataGroupImpl = class {
3992
4006
  } catch {
3993
4007
  }
3994
4008
  }
4009
+ if (!isMtimeSidecar(normalized)) {
4010
+ try {
4011
+ await this.localFS.unlink(`${normalized}.mtime`);
4012
+ } catch {
4013
+ }
4014
+ }
3995
4015
  this.schedulePostDeleteSync();
3996
4016
  }
3997
4017
  schedulePostDeleteSync() {
package/dist/index.mjs CHANGED
@@ -960,6 +960,9 @@ async function existsSafe(fs, path) {
960
960
  return false;
961
961
  }
962
962
  }
963
+ function isMtimeSidecarPath(path) {
964
+ return path.endsWith(".mtime");
965
+ }
963
966
  function encodeMetaPath(filePath) {
964
967
  const normalized = filePath.startsWith("/") ? filePath : `/${filePath}`;
965
968
  return normalized.replace(/^\//, "").replace(/\//g, "__").replace(/\./g, "++");
@@ -1052,7 +1055,7 @@ var TombstoneStore = class {
1052
1055
  }
1053
1056
  }
1054
1057
  async deleteEverywhere(fs, filePath) {
1055
- if (!await existsSafe(fs, filePath)) return;
1058
+ if (!isMtimeSidecarPath(filePath) && !await existsSafe(fs, filePath)) return;
1056
1059
  try {
1057
1060
  await fs.unlink(filePath);
1058
1061
  } catch {
@@ -1636,7 +1639,9 @@ var ConfigRepo = class {
1636
1639
  const files = await collectFilesUnder(this.cachedFS, normalizedPath);
1637
1640
  for (const file of files) await this.deleteFile(file);
1638
1641
  for (const dir of await collectDirectoriesUnder(this.cachedFS, normalizedPath)) {
1639
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
1642
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
1643
+ await this.writeTombstoneFor(keepPath);
1644
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
1640
1645
  }
1641
1646
  await removeDirectoryTree(this.cachedFS, normalizedPath);
1642
1647
  this.invalidateTombstoneCache();
@@ -1656,6 +1661,12 @@ var ConfigRepo = class {
1656
1661
  } catch {
1657
1662
  }
1658
1663
  }
1664
+ if (!isMtimeSidecar(normalizedPath)) {
1665
+ try {
1666
+ await this.cachedFS.unlink(`${normalizedPath}.mtime`);
1667
+ } catch {
1668
+ }
1669
+ }
1659
1670
  log2.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePathFor(normalizedPath)})`);
1660
1671
  this.invalidateTombstoneCache();
1661
1672
  this.schedulePostDeleteSync();
@@ -1734,9 +1745,10 @@ var ConfigRepo = class {
1734
1745
  let processed = 0;
1735
1746
  let alreadyDeleted = 0;
1736
1747
  for (const tombstone of tombstones) {
1737
- const tVersionPath = versionPathFor(tombstone.path);
1738
- log2.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"}`);
1739
- const existedOnPrimary = await this.safeExists(this.cachedFS, tombstone.path);
1748
+ const forceDelete = isMtimeSidecar(tombstone.path);
1749
+ const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
1750
+ log2.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"} forceDelete=${forceDelete}`);
1751
+ const existedOnPrimary = forceDelete || await this.safeExists(this.cachedFS, tombstone.path);
1740
1752
  log2.log(`[TOMB-TRACE] primary safeExists(${tombstone.path}) \u2192 ${existedOnPrimary}`);
1741
1753
  if (existedOnPrimary) {
1742
1754
  log2.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on primary \u2192 EXISTS`);
@@ -1760,7 +1772,7 @@ var ConfigRepo = class {
1760
1772
  }
1761
1773
  for (const [replicaId, replica] of this.replicaBackends) {
1762
1774
  log2.log(`[TOMB-TRACE] checking replica: ${replicaId} for ${tombstone.path}`);
1763
- const existed = await this.safeExists(replica.instance, tombstone.path);
1775
+ const existed = forceDelete || await this.safeExists(replica.instance, tombstone.path);
1764
1776
  log2.log(`[TOMB-TRACE] replica ${replicaId} safeExists(${tombstone.path}) \u2192 ${existed}`);
1765
1777
  if (existed) {
1766
1778
  log2.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on ${replicaId} \u2192 EXISTS`);
@@ -3418,7 +3430,9 @@ var AppDataGroupImpl = class {
3418
3430
  const files = await collectFilesUnder(this.localFS, normalized);
3419
3431
  for (const file of files) await this.deleteFile(file);
3420
3432
  for (const dir of await collectDirectoriesUnder(this.localFS, normalized)) {
3421
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
3433
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
3434
+ await this.writeTombstoneFor(keepPath);
3435
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
3422
3436
  }
3423
3437
  await removeDirectoryTree(this.localFS, normalized);
3424
3438
  this.schedulePostDeleteSync();
@@ -3437,6 +3451,12 @@ var AppDataGroupImpl = class {
3437
3451
  } catch {
3438
3452
  }
3439
3453
  }
3454
+ if (!isMtimeSidecar(normalized)) {
3455
+ try {
3456
+ await this.localFS.unlink(`${normalized}.mtime`);
3457
+ } catch {
3458
+ }
3459
+ }
3440
3460
  this.schedulePostDeleteSync();
3441
3461
  }
3442
3462
  schedulePostDeleteSync() {
@@ -27540,6 +27540,9 @@ var ZenFSConfig = (() => {
27540
27540
  return false;
27541
27541
  }
27542
27542
  }
27543
+ function isMtimeSidecarPath(path) {
27544
+ return path.endsWith(".mtime");
27545
+ }
27543
27546
  function encodeMetaPath(filePath) {
27544
27547
  const normalized = filePath.startsWith("/") ? filePath : `/${filePath}`;
27545
27548
  return normalized.replace(/^\//, "").replace(/\//g, "__").replace(/\./g, "++");
@@ -27630,7 +27633,7 @@ var ZenFSConfig = (() => {
27630
27633
  }
27631
27634
  }
27632
27635
  async deleteEverywhere(fs, filePath) {
27633
- if (!await existsSafe(fs, filePath)) return;
27636
+ if (!isMtimeSidecarPath(filePath) && !await existsSafe(fs, filePath)) return;
27634
27637
  try {
27635
27638
  await fs.unlink(filePath);
27636
27639
  } catch {
@@ -28214,7 +28217,9 @@ var ZenFSConfig = (() => {
28214
28217
  const files = await collectFilesUnder(this.cachedFS, normalizedPath);
28215
28218
  for (const file of files) await this.deleteFile(file);
28216
28219
  for (const dir of await collectDirectoriesUnder(this.cachedFS, normalizedPath)) {
28217
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
28220
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
28221
+ await this.writeTombstoneFor(keepPath);
28222
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
28218
28223
  }
28219
28224
  await removeDirectoryTree(this.cachedFS, normalizedPath);
28220
28225
  this.invalidateTombstoneCache();
@@ -28234,6 +28239,12 @@ var ZenFSConfig = (() => {
28234
28239
  } catch {
28235
28240
  }
28236
28241
  }
28242
+ if (!isMtimeSidecar(normalizedPath)) {
28243
+ try {
28244
+ await this.cachedFS.unlink(`${normalizedPath}.mtime`);
28245
+ } catch {
28246
+ }
28247
+ }
28237
28248
  log6.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePathFor(normalizedPath)})`);
28238
28249
  this.invalidateTombstoneCache();
28239
28250
  this.schedulePostDeleteSync();
@@ -28306,9 +28317,10 @@ var ZenFSConfig = (() => {
28306
28317
  let processed = 0;
28307
28318
  let alreadyDeleted = 0;
28308
28319
  for (const tombstone of tombstones) {
28309
- const tVersionPath = versionPathFor(tombstone.path);
28310
- log6.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"}`);
28311
- const existedOnPrimary = await this.safeExists(this.cachedFS, tombstone.path);
28320
+ const forceDelete = isMtimeSidecar(tombstone.path);
28321
+ const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
28322
+ log6.log(`[TOMB-TRACE] processing tombstone: path=${tombstone.path} versionPath=${tVersionPath ?? "null"} forceDelete=${forceDelete}`);
28323
+ const existedOnPrimary = forceDelete || await this.safeExists(this.cachedFS, tombstone.path);
28312
28324
  log6.log(`[TOMB-TRACE] primary safeExists(${tombstone.path}) \u2192 ${existedOnPrimary}`);
28313
28325
  if (existedOnPrimary) {
28314
28326
  log6.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on primary \u2192 EXISTS`);
@@ -28332,7 +28344,7 @@ var ZenFSConfig = (() => {
28332
28344
  }
28333
28345
  for (const [replicaId, replica] of this.replicaBackends) {
28334
28346
  log6.log(`[TOMB-TRACE] checking replica: ${replicaId} for ${tombstone.path}`);
28335
- const existed = await this.safeExists(replica.instance, tombstone.path);
28347
+ const existed = forceDelete || await this.safeExists(replica.instance, tombstone.path);
28336
28348
  log6.log(`[TOMB-TRACE] replica ${replicaId} safeExists(${tombstone.path}) \u2192 ${existed}`);
28337
28349
  if (existed) {
28338
28350
  log6.log(`[TOMB-TRACE] tombstone check: ${tombstone.path} on ${replicaId} \u2192 EXISTS`);
@@ -29990,7 +30002,9 @@ var ZenFSConfig = (() => {
29990
30002
  const files = await collectFilesUnder(this.localFS, normalized);
29991
30003
  for (const file of files) await this.deleteFile(file);
29992
30004
  for (const dir of await collectDirectoriesUnder(this.localFS, normalized)) {
29993
- await this.writeTombstoneFor(dir === "/" ? "/.keep" : `${dir}/.keep`);
30005
+ const keepPath = dir === "/" ? "/.keep" : `${dir}/.keep`;
30006
+ await this.writeTombstoneFor(keepPath);
30007
+ await this.writeTombstoneFor(`${keepPath}.mtime`);
29994
30008
  }
29995
30009
  await removeDirectoryTree(this.localFS, normalized);
29996
30010
  this.schedulePostDeleteSync();
@@ -30009,6 +30023,12 @@ var ZenFSConfig = (() => {
30009
30023
  } catch {
30010
30024
  }
30011
30025
  }
30026
+ if (!isMtimeSidecar(normalized)) {
30027
+ try {
30028
+ await this.localFS.unlink(`${normalized}.mtime`);
30029
+ } catch {
30030
+ }
30031
+ }
30012
30032
  this.schedulePostDeleteSync();
30013
30033
  }
30014
30034
  schedulePostDeleteSync() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.5.50",
3
+ "version": "0.5.51",
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",