zen-fs-config 0.3.20 → 0.3.21
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 +12 -7
- package/dist/index.mjs +12 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -679,10 +679,13 @@ var ConfigRepo = class {
|
|
|
679
679
|
for (const metaFile of [BACKENDS_FILE, SYNC_RULES_FILE]) {
|
|
680
680
|
try {
|
|
681
681
|
const content = await this.cachedFS.readFile(metaFile);
|
|
682
|
+
const vPath = versionPathFor(metaFile);
|
|
683
|
+
const vContent = await this.cachedFS.readFile(vPath);
|
|
682
684
|
for (const [id, replica] of this.replicaBackends) {
|
|
683
685
|
try {
|
|
684
686
|
await replica.syncable.writeFile(metaFile, content);
|
|
685
|
-
|
|
687
|
+
await replica.syncable.writeFile(vPath, vContent);
|
|
688
|
+
console.log(`[ConfigRepo] Synced ${metaFile} + .version to replica ${id}`);
|
|
686
689
|
} catch (err) {
|
|
687
690
|
console.error(`[ConfigRepo] Failed to sync ${metaFile} to ${id}:`, err.message);
|
|
688
691
|
}
|
|
@@ -927,12 +930,14 @@ var ConfigRepo = class {
|
|
|
927
930
|
async writeMetaFile(path, data) {
|
|
928
931
|
console.log(`[writeMetaFile] ${path}, ensuring dir...`);
|
|
929
932
|
await this.ensureDir(path);
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
);
|
|
935
|
-
|
|
933
|
+
const bytes = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
|
934
|
+
console.log(`[writeMetaFile] ${path}, writing ${bytes.length} bytes...`);
|
|
935
|
+
await this.cachedFS.writeFile(path, bytes);
|
|
936
|
+
const author = `${this.appId}/${this.nodeId}`;
|
|
937
|
+
const version = await incrementVersion(this.fullFS, path, bytes, author);
|
|
938
|
+
await this.ensureDir(versionPathFor(path));
|
|
939
|
+
await writeVersion(this.fullFS, versionPathFor(path), version);
|
|
940
|
+
console.log(`[writeMetaFile] ${path} done (version=${version.version})`);
|
|
936
941
|
}
|
|
937
942
|
async readMetaFile(path) {
|
|
938
943
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -630,10 +630,13 @@ var ConfigRepo = class {
|
|
|
630
630
|
for (const metaFile of [BACKENDS_FILE, SYNC_RULES_FILE]) {
|
|
631
631
|
try {
|
|
632
632
|
const content = await this.cachedFS.readFile(metaFile);
|
|
633
|
+
const vPath = versionPathFor(metaFile);
|
|
634
|
+
const vContent = await this.cachedFS.readFile(vPath);
|
|
633
635
|
for (const [id, replica] of this.replicaBackends) {
|
|
634
636
|
try {
|
|
635
637
|
await replica.syncable.writeFile(metaFile, content);
|
|
636
|
-
|
|
638
|
+
await replica.syncable.writeFile(vPath, vContent);
|
|
639
|
+
console.log(`[ConfigRepo] Synced ${metaFile} + .version to replica ${id}`);
|
|
637
640
|
} catch (err) {
|
|
638
641
|
console.error(`[ConfigRepo] Failed to sync ${metaFile} to ${id}:`, err.message);
|
|
639
642
|
}
|
|
@@ -878,12 +881,14 @@ var ConfigRepo = class {
|
|
|
878
881
|
async writeMetaFile(path, data) {
|
|
879
882
|
console.log(`[writeMetaFile] ${path}, ensuring dir...`);
|
|
880
883
|
await this.ensureDir(path);
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
);
|
|
886
|
-
|
|
884
|
+
const bytes = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
|
885
|
+
console.log(`[writeMetaFile] ${path}, writing ${bytes.length} bytes...`);
|
|
886
|
+
await this.cachedFS.writeFile(path, bytes);
|
|
887
|
+
const author = `${this.appId}/${this.nodeId}`;
|
|
888
|
+
const version = await incrementVersion(this.fullFS, path, bytes, author);
|
|
889
|
+
await this.ensureDir(versionPathFor(path));
|
|
890
|
+
await writeVersion(this.fullFS, versionPathFor(path), version);
|
|
891
|
+
console.log(`[writeMetaFile] ${path} done (version=${version.version})`);
|
|
887
892
|
}
|
|
888
893
|
async readMetaFile(path) {
|
|
889
894
|
try {
|