zen-fs-config 0.6.3 → 0.6.4

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
@@ -2584,11 +2584,16 @@ var ConfigRepo = class {
2584
2584
  const isKeepPlaceholder = tombstone.path === "/.keep" || tombstone.path.endsWith("/.keep");
2585
2585
  const forceDelete = isMtimeSidecar(tombstone.path) || isKeepPlaceholder;
2586
2586
  const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
2587
+ const sidecarOwner = sidecarOwnerPath(tombstone.path);
2588
+ const isKeepSidecar = sidecarOwner === "/.keep" || (sidecarOwner?.endsWith("/.keep") ?? false);
2589
+ const liveSidecarCandidate = sidecarOwner !== null && !isKeepSidecar;
2587
2590
  if (forceDelete) {
2588
- try {
2589
- await this.cachedFS.unlink(tombstone.path);
2590
- processed++;
2591
- } catch {
2591
+ if (!(liveSidecarCandidate && await this.pathExistsOnBackend(this.cachedFS, sidecarOwner))) {
2592
+ try {
2593
+ await this.cachedFS.unlink(tombstone.path);
2594
+ processed++;
2595
+ } catch {
2596
+ }
2592
2597
  }
2593
2598
  } else {
2594
2599
  const existedOnPrimary = await this.pathExistsOnBackend(this.cachedFS, tombstone.path);
@@ -2602,13 +2607,18 @@ var ConfigRepo = class {
2602
2607
  for (const [replicaId, replica] of this.replicaBackends) {
2603
2608
  let gone;
2604
2609
  if (forceDelete) {
2605
- try {
2606
- await replica.instance.unlink(tombstone.path);
2610
+ if (liveSidecarCandidate && await this.pathExistsOnBackend(replica.instance, sidecarOwner)) {
2607
2611
  gone = true;
2608
- } catch (err) {
2609
- gone = isNotFoundError(err);
2612
+ alreadyDeleted++;
2613
+ } else {
2614
+ try {
2615
+ await replica.instance.unlink(tombstone.path);
2616
+ gone = true;
2617
+ } catch (err) {
2618
+ gone = isNotFoundError(err);
2619
+ }
2620
+ if (gone) processed++;
2610
2621
  }
2611
- if (gone) processed++;
2612
2622
  } else {
2613
2623
  const existed = await this.pathExistsOnBackend(replica.instance, tombstone.path);
2614
2624
  gone = await this.purgePathOnBackend(replica.instance, tombstone.path);
@@ -4950,6 +4960,13 @@ async function createConfigRepo(appId, options = {}) {
4950
4960
  });
4951
4961
  return repo;
4952
4962
  }
4963
+ function sidecarOwnerPath(path) {
4964
+ let owner = null;
4965
+ if (path.endsWith(".mtime")) owner = path.slice(0, -".mtime".length);
4966
+ else if (path.endsWith(".version")) owner = path.slice(0, -".version".length);
4967
+ if (owner && owner.endsWith(".version")) owner = owner.slice(0, -".version".length);
4968
+ return owner === "" ? null : owner;
4969
+ }
4953
4970
 
4954
4971
  // src/connect.ts
4955
4972
  init_backend_registry();
package/dist/index.mjs CHANGED
@@ -2029,11 +2029,16 @@ var ConfigRepo = class {
2029
2029
  const isKeepPlaceholder = tombstone.path === "/.keep" || tombstone.path.endsWith("/.keep");
2030
2030
  const forceDelete = isMtimeSidecar(tombstone.path) || isKeepPlaceholder;
2031
2031
  const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
2032
+ const sidecarOwner = sidecarOwnerPath(tombstone.path);
2033
+ const isKeepSidecar = sidecarOwner === "/.keep" || (sidecarOwner?.endsWith("/.keep") ?? false);
2034
+ const liveSidecarCandidate = sidecarOwner !== null && !isKeepSidecar;
2032
2035
  if (forceDelete) {
2033
- try {
2034
- await this.cachedFS.unlink(tombstone.path);
2035
- processed++;
2036
- } catch {
2036
+ if (!(liveSidecarCandidate && await this.pathExistsOnBackend(this.cachedFS, sidecarOwner))) {
2037
+ try {
2038
+ await this.cachedFS.unlink(tombstone.path);
2039
+ processed++;
2040
+ } catch {
2041
+ }
2037
2042
  }
2038
2043
  } else {
2039
2044
  const existedOnPrimary = await this.pathExistsOnBackend(this.cachedFS, tombstone.path);
@@ -2047,13 +2052,18 @@ var ConfigRepo = class {
2047
2052
  for (const [replicaId, replica] of this.replicaBackends) {
2048
2053
  let gone;
2049
2054
  if (forceDelete) {
2050
- try {
2051
- await replica.instance.unlink(tombstone.path);
2055
+ if (liveSidecarCandidate && await this.pathExistsOnBackend(replica.instance, sidecarOwner)) {
2052
2056
  gone = true;
2053
- } catch (err) {
2054
- gone = isNotFoundError(err);
2057
+ alreadyDeleted++;
2058
+ } else {
2059
+ try {
2060
+ await replica.instance.unlink(tombstone.path);
2061
+ gone = true;
2062
+ } catch (err) {
2063
+ gone = isNotFoundError(err);
2064
+ }
2065
+ if (gone) processed++;
2055
2066
  }
2056
- if (gone) processed++;
2057
2067
  } else {
2058
2068
  const existed = await this.pathExistsOnBackend(replica.instance, tombstone.path);
2059
2069
  gone = await this.purgePathOnBackend(replica.instance, tombstone.path);
@@ -4395,6 +4405,13 @@ async function createConfigRepo(appId, options = {}) {
4395
4405
  });
4396
4406
  return repo;
4397
4407
  }
4408
+ function sidecarOwnerPath(path) {
4409
+ let owner = null;
4410
+ if (path.endsWith(".mtime")) owner = path.slice(0, -".mtime".length);
4411
+ else if (path.endsWith(".version")) owner = path.slice(0, -".version".length);
4412
+ if (owner && owner.endsWith(".version")) owner = owner.slice(0, -".version".length);
4413
+ return owner === "" ? null : owner;
4414
+ }
4398
4415
 
4399
4416
  // src/connect.ts
4400
4417
  var log4 = createLogger("connect");
@@ -28598,11 +28598,16 @@ var ZenFSConfig = (() => {
28598
28598
  const isKeepPlaceholder = tombstone.path === "/.keep" || tombstone.path.endsWith("/.keep");
28599
28599
  const forceDelete = isMtimeSidecar(tombstone.path) || isKeepPlaceholder;
28600
28600
  const tVersionPath = forceDelete ? null : versionPathFor(tombstone.path);
28601
+ const sidecarOwner = sidecarOwnerPath(tombstone.path);
28602
+ const isKeepSidecar = sidecarOwner === "/.keep" || (sidecarOwner?.endsWith("/.keep") ?? false);
28603
+ const liveSidecarCandidate = sidecarOwner !== null && !isKeepSidecar;
28601
28604
  if (forceDelete) {
28602
- try {
28603
- await this.cachedFS.unlink(tombstone.path);
28604
- processed++;
28605
- } catch {
28605
+ if (!(liveSidecarCandidate && await this.pathExistsOnBackend(this.cachedFS, sidecarOwner))) {
28606
+ try {
28607
+ await this.cachedFS.unlink(tombstone.path);
28608
+ processed++;
28609
+ } catch {
28610
+ }
28606
28611
  }
28607
28612
  } else {
28608
28613
  const existedOnPrimary = await this.pathExistsOnBackend(this.cachedFS, tombstone.path);
@@ -28616,13 +28621,18 @@ var ZenFSConfig = (() => {
28616
28621
  for (const [replicaId, replica] of this.replicaBackends) {
28617
28622
  let gone;
28618
28623
  if (forceDelete) {
28619
- try {
28620
- await replica.instance.unlink(tombstone.path);
28624
+ if (liveSidecarCandidate && await this.pathExistsOnBackend(replica.instance, sidecarOwner)) {
28621
28625
  gone = true;
28622
- } catch (err2) {
28623
- gone = isNotFoundError(err2);
28626
+ alreadyDeleted++;
28627
+ } else {
28628
+ try {
28629
+ await replica.instance.unlink(tombstone.path);
28630
+ gone = true;
28631
+ } catch (err2) {
28632
+ gone = isNotFoundError(err2);
28633
+ }
28634
+ if (gone) processed++;
28624
28635
  }
28625
- if (gone) processed++;
28626
28636
  } else {
28627
28637
  const existed = await this.pathExistsOnBackend(replica.instance, tombstone.path);
28628
28638
  gone = await this.purgePathOnBackend(replica.instance, tombstone.path);
@@ -30964,6 +30974,13 @@ var ZenFSConfig = (() => {
30964
30974
  });
30965
30975
  return repo;
30966
30976
  }
30977
+ function sidecarOwnerPath(path) {
30978
+ let owner = null;
30979
+ if (path.endsWith(".mtime")) owner = path.slice(0, -".mtime".length);
30980
+ else if (path.endsWith(".version")) owner = path.slice(0, -".version".length);
30981
+ if (owner && owner.endsWith(".version")) owner = owner.slice(0, -".version".length);
30982
+ return owner === "" ? null : owner;
30983
+ }
30967
30984
 
30968
30985
  // src/connect.ts
30969
30986
  init_backend_registry();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
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",