@rljson/fs-agent 0.0.47 → 0.0.49
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/fs-agent.d.ts +8 -0
- package/dist/fs-agent.js +46 -5
- package/package.json +1 -1
package/dist/fs-agent.d.ts
CHANGED
|
@@ -276,6 +276,14 @@ export declare class FsAgent {
|
|
|
276
276
|
/** Files written vs left alone by the current {@link restore}. */
|
|
277
277
|
private _restoreWritten;
|
|
278
278
|
private _restoreSkipped;
|
|
279
|
+
/**
|
|
280
|
+
* The file set of the newest tree any peer has told this node about.
|
|
281
|
+
*
|
|
282
|
+
* Kept so the SEND path can answer the one question a receiver never can:
|
|
283
|
+
* am I about to announce a state that is merely my progress through someone
|
|
284
|
+
* else's? See the check in `syncToDb`.
|
|
285
|
+
*/
|
|
286
|
+
private _lastKnownRemoteFiles?;
|
|
279
287
|
/**
|
|
280
288
|
* Files this restore DELETED.
|
|
281
289
|
*
|
package/dist/fs-agent.js
CHANGED
|
@@ -1152,6 +1152,14 @@ class FsAgent {
|
|
|
1152
1152
|
/** Files written vs left alone by the current {@link restore}. */
|
|
1153
1153
|
_restoreWritten = 0;
|
|
1154
1154
|
_restoreSkipped = 0;
|
|
1155
|
+
/**
|
|
1156
|
+
* The file set of the newest tree any peer has told this node about.
|
|
1157
|
+
*
|
|
1158
|
+
* Kept so the SEND path can answer the one question a receiver never can:
|
|
1159
|
+
* am I about to announce a state that is merely my progress through someone
|
|
1160
|
+
* else's? See the check in `syncToDb`.
|
|
1161
|
+
*/
|
|
1162
|
+
_lastKnownRemoteFiles;
|
|
1155
1163
|
/**
|
|
1156
1164
|
* Files this restore DELETED.
|
|
1157
1165
|
*
|
|
@@ -2021,6 +2029,25 @@ ${err.stack}` : String(err);
|
|
|
2021
2029
|
if (contentKey === this._lastSentContentKey) {
|
|
2022
2030
|
return;
|
|
2023
2031
|
}
|
|
2032
|
+
const known = this._lastKnownRemoteFiles;
|
|
2033
|
+
if (known && tree.trees.size > 0) {
|
|
2034
|
+
const mine = this._getFileContentMap(tree);
|
|
2035
|
+
if (mine.size < known.size) {
|
|
2036
|
+
let hasOwn = false;
|
|
2037
|
+
for (const path of mine.keys()) {
|
|
2038
|
+
if (!known.has(path)) {
|
|
2039
|
+
hasOwn = true;
|
|
2040
|
+
break;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
if (!hasOwn) {
|
|
2044
|
+
console.log(
|
|
2045
|
+
`[FsAgent] not announcing ${mine.size} of ${known.size} files — this node is still catching up, and that is a gap rather than news.`
|
|
2046
|
+
);
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2024
2051
|
const dbAdapter = new FsDbAdapter(db, treeKey);
|
|
2025
2052
|
const parentRef = this._currentRef;
|
|
2026
2053
|
const previous = await this._ancestryPrevious(
|
|
@@ -2431,10 +2458,10 @@ ${err.stack}` : String(err);
|
|
|
2431
2458
|
`syncFromDb → extract(${this._rootPath})`
|
|
2432
2459
|
);
|
|
2433
2460
|
if (this._treesHaveEquivalentContent(currentTree, incomingTree)) {
|
|
2434
|
-
const
|
|
2461
|
+
const incomingFiles2 = this._getFileContentMap(incomingTree);
|
|
2435
2462
|
const currentFiles = this._getFileContentMap(currentTree);
|
|
2436
2463
|
console.log(
|
|
2437
|
-
`[FsAgent] syncFromDb: equivalent content, skipping restore (incoming=${
|
|
2464
|
+
`[FsAgent] syncFromDb: equivalent content, skipping restore (incoming=${incomingFiles2.size} entries, current=${currentFiles.size} entries, ref=${treeRef.slice(0, 8)}…)`
|
|
2438
2465
|
);
|
|
2439
2466
|
this._adoptAppliedRef(connector, treeRef);
|
|
2440
2467
|
this._currentRef = treeRef;
|
|
@@ -2496,10 +2523,24 @@ ${err.stack}` : String(err);
|
|
|
2496
2523
|
this._adoptAppliedRef(connector, treeRef);
|
|
2497
2524
|
this._currentRef = postRestoreRef;
|
|
2498
2525
|
this._persistCurrentRef(postRestoreRef);
|
|
2499
|
-
const
|
|
2500
|
-
|
|
2526
|
+
const postRestoreFiles = this._getFileContentMap(postRestoreTree);
|
|
2527
|
+
const incomingFiles = this._getFileContentMap(incomingTree);
|
|
2528
|
+
this._lastKnownRemoteFiles = incomingFiles;
|
|
2529
|
+
let hasNewsOfOurOwn = false;
|
|
2530
|
+
for (const path of postRestoreFiles.keys()) {
|
|
2531
|
+
if (!incomingFiles.has(path)) {
|
|
2532
|
+
hasNewsOfOurOwn = true;
|
|
2533
|
+
break;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
if (!hasNewsOfOurOwn) {
|
|
2501
2537
|
this._lastSentRef = postRestoreRef;
|
|
2502
|
-
this._lastSentContentKey =
|
|
2538
|
+
this._lastSentContentKey = this._contentKeyFromTree(postRestoreTree);
|
|
2539
|
+
if (postRestoreFiles.size < incomingFiles.size) {
|
|
2540
|
+
console.log(
|
|
2541
|
+
`[FsAgent] ref=${treeRef.slice(0, 8)}… left this node behind (${postRestoreFiles.size} of ${incomingFiles.size} files) — not announcing a state that is catching up.`
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2503
2544
|
}
|
|
2504
2545
|
return;
|
|
2505
2546
|
} catch (err) {
|