zen-fs-config 0.5.6 → 0.5.7
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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -0
- package/dist/index.mjs +16 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -462,6 +462,8 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
462
462
|
private configCache;
|
|
463
463
|
private readonly primaryBackendId;
|
|
464
464
|
private readonly pollIntervalMs?;
|
|
465
|
+
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
466
|
+
private tombstoneCache;
|
|
465
467
|
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number);
|
|
466
468
|
/** Full path to this node's directory on the primary backend. */
|
|
467
469
|
get nodePath(): string;
|
|
@@ -484,8 +486,11 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
484
486
|
deleteFile(path: string): Promise<void>;
|
|
485
487
|
/**
|
|
486
488
|
* Read all tombstones from the primary backend.
|
|
489
|
+
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
487
490
|
*/
|
|
488
491
|
private readTombstones;
|
|
492
|
+
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
493
|
+
private invalidateTombstoneCache;
|
|
489
494
|
/**
|
|
490
495
|
* Before sync: for each tombstone, delete the actual file on all replicas.
|
|
491
496
|
* This prevents bi-directional sync from copying the file back.
|
package/dist/index.d.ts
CHANGED
|
@@ -462,6 +462,8 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
462
462
|
private configCache;
|
|
463
463
|
private readonly primaryBackendId;
|
|
464
464
|
private readonly pollIntervalMs?;
|
|
465
|
+
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
466
|
+
private tombstoneCache;
|
|
465
467
|
constructor(appId: string, nodeId: string, primaryBackendId: string, cachedFS: MinimalAsyncFS, serializer: PathAwareSerializer, onConflict?: (conflict: ConflictInfo) => Promise<unknown | null>, pollIntervalMs?: number);
|
|
466
468
|
/** Full path to this node's directory on the primary backend. */
|
|
467
469
|
get nodePath(): string;
|
|
@@ -484,8 +486,11 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
484
486
|
deleteFile(path: string): Promise<void>;
|
|
485
487
|
/**
|
|
486
488
|
* Read all tombstones from the primary backend.
|
|
489
|
+
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
487
490
|
*/
|
|
488
491
|
private readTombstones;
|
|
492
|
+
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
493
|
+
private invalidateTombstoneCache;
|
|
489
494
|
/**
|
|
490
495
|
* Before sync: for each tombstone, delete the actual file on all replicas.
|
|
491
496
|
* This prevents bi-directional sync from copying the file back.
|
package/dist/index.js
CHANGED
|
@@ -586,6 +586,8 @@ var ConfigRepo = class {
|
|
|
586
586
|
configCache = /* @__PURE__ */ new Map();
|
|
587
587
|
primaryBackendId;
|
|
588
588
|
pollIntervalMs;
|
|
589
|
+
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
590
|
+
tombstoneCache = null;
|
|
589
591
|
constructor(appId, nodeId, primaryBackendId, cachedFS, serializer, onConflict, pollIntervalMs) {
|
|
590
592
|
this.appId = appId;
|
|
591
593
|
this.nodeId = nodeId;
|
|
@@ -746,10 +748,12 @@ var ConfigRepo = class {
|
|
|
746
748
|
this.assertNotDisposed();
|
|
747
749
|
await this.processTombstones();
|
|
748
750
|
const resultsMap = await this.syncEngine.syncAll();
|
|
751
|
+
this.invalidateTombstoneCache();
|
|
749
752
|
await this.readAllBackendDescriptors();
|
|
750
753
|
await this.processTombstones();
|
|
751
754
|
await this.updateTombstoneConfirmations();
|
|
752
755
|
await this.gcTombstones();
|
|
756
|
+
this.invalidateTombstoneCache();
|
|
753
757
|
return Array.from(resultsMap.values());
|
|
754
758
|
}
|
|
755
759
|
// -----------------------------------------------------------------------
|
|
@@ -786,11 +790,16 @@ var ConfigRepo = class {
|
|
|
786
790
|
}
|
|
787
791
|
}
|
|
788
792
|
console.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePath})`);
|
|
793
|
+
this.invalidateTombstoneCache();
|
|
789
794
|
}
|
|
790
795
|
/**
|
|
791
796
|
* Read all tombstones from the primary backend.
|
|
797
|
+
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
792
798
|
*/
|
|
793
799
|
async readTombstones() {
|
|
800
|
+
if (this.tombstoneCache !== null) {
|
|
801
|
+
return this.tombstoneCache;
|
|
802
|
+
}
|
|
794
803
|
try {
|
|
795
804
|
const entries = await this.cachedFS.readdir(DELETIONS_DIR);
|
|
796
805
|
const tombstones = [];
|
|
@@ -803,11 +812,17 @@ var ConfigRepo = class {
|
|
|
803
812
|
} catch {
|
|
804
813
|
}
|
|
805
814
|
}
|
|
815
|
+
this.tombstoneCache = tombstones;
|
|
806
816
|
return tombstones;
|
|
807
817
|
} catch {
|
|
818
|
+
this.tombstoneCache = [];
|
|
808
819
|
return [];
|
|
809
820
|
}
|
|
810
821
|
}
|
|
822
|
+
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
823
|
+
invalidateTombstoneCache() {
|
|
824
|
+
this.tombstoneCache = null;
|
|
825
|
+
}
|
|
811
826
|
/**
|
|
812
827
|
* Before sync: for each tombstone, delete the actual file on all replicas.
|
|
813
828
|
* This prevents bi-directional sync from copying the file back.
|
|
@@ -883,6 +898,7 @@ var ConfigRepo = class {
|
|
|
883
898
|
}
|
|
884
899
|
}
|
|
885
900
|
console.log(`[ConfigRepo] updateTombstoneConfirmations: ${tombstones.length} tombstone(s) updated`);
|
|
901
|
+
this.invalidateTombstoneCache();
|
|
886
902
|
}
|
|
887
903
|
/**
|
|
888
904
|
* GC: remove tombstones where all backends in backends.json have confirmed.
|
package/dist/index.mjs
CHANGED
|
@@ -529,6 +529,8 @@ var ConfigRepo = class {
|
|
|
529
529
|
configCache = /* @__PURE__ */ new Map();
|
|
530
530
|
primaryBackendId;
|
|
531
531
|
pollIntervalMs;
|
|
532
|
+
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
533
|
+
tombstoneCache = null;
|
|
532
534
|
constructor(appId, nodeId, primaryBackendId, cachedFS, serializer, onConflict, pollIntervalMs) {
|
|
533
535
|
this.appId = appId;
|
|
534
536
|
this.nodeId = nodeId;
|
|
@@ -689,10 +691,12 @@ var ConfigRepo = class {
|
|
|
689
691
|
this.assertNotDisposed();
|
|
690
692
|
await this.processTombstones();
|
|
691
693
|
const resultsMap = await this.syncEngine.syncAll();
|
|
694
|
+
this.invalidateTombstoneCache();
|
|
692
695
|
await this.readAllBackendDescriptors();
|
|
693
696
|
await this.processTombstones();
|
|
694
697
|
await this.updateTombstoneConfirmations();
|
|
695
698
|
await this.gcTombstones();
|
|
699
|
+
this.invalidateTombstoneCache();
|
|
696
700
|
return Array.from(resultsMap.values());
|
|
697
701
|
}
|
|
698
702
|
// -----------------------------------------------------------------------
|
|
@@ -729,11 +733,16 @@ var ConfigRepo = class {
|
|
|
729
733
|
}
|
|
730
734
|
}
|
|
731
735
|
console.log(`[ConfigRepo] deleteFile: ${normalizedPath} (tombstone at ${tombstonePath})`);
|
|
736
|
+
this.invalidateTombstoneCache();
|
|
732
737
|
}
|
|
733
738
|
/**
|
|
734
739
|
* Read all tombstones from the primary backend.
|
|
740
|
+
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
735
741
|
*/
|
|
736
742
|
async readTombstones() {
|
|
743
|
+
if (this.tombstoneCache !== null) {
|
|
744
|
+
return this.tombstoneCache;
|
|
745
|
+
}
|
|
737
746
|
try {
|
|
738
747
|
const entries = await this.cachedFS.readdir(DELETIONS_DIR);
|
|
739
748
|
const tombstones = [];
|
|
@@ -746,11 +755,17 @@ var ConfigRepo = class {
|
|
|
746
755
|
} catch {
|
|
747
756
|
}
|
|
748
757
|
}
|
|
758
|
+
this.tombstoneCache = tombstones;
|
|
749
759
|
return tombstones;
|
|
750
760
|
} catch {
|
|
761
|
+
this.tombstoneCache = [];
|
|
751
762
|
return [];
|
|
752
763
|
}
|
|
753
764
|
}
|
|
765
|
+
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
766
|
+
invalidateTombstoneCache() {
|
|
767
|
+
this.tombstoneCache = null;
|
|
768
|
+
}
|
|
754
769
|
/**
|
|
755
770
|
* Before sync: for each tombstone, delete the actual file on all replicas.
|
|
756
771
|
* This prevents bi-directional sync from copying the file back.
|
|
@@ -826,6 +841,7 @@ var ConfigRepo = class {
|
|
|
826
841
|
}
|
|
827
842
|
}
|
|
828
843
|
console.log(`[ConfigRepo] updateTombstoneConfirmations: ${tombstones.length} tombstone(s) updated`);
|
|
844
|
+
this.invalidateTombstoneCache();
|
|
829
845
|
}
|
|
830
846
|
/**
|
|
831
847
|
* GC: remove tombstones where all backends in backends.json have confirmed.
|