@rljson/fs-agent 0.0.46 → 0.0.48
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 +10 -0
- package/dist/fs-agent.js +37 -7
- package/package.json +1 -1
package/dist/fs-agent.d.ts
CHANGED
|
@@ -276,6 +276,16 @@ 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
|
+
* Files this restore DELETED.
|
|
281
|
+
*
|
|
282
|
+
* Counted and reported because a prune is the only half of a restore that
|
|
283
|
+
* can destroy anything, and until now it was the only half that happened
|
|
284
|
+
* silently: `restore: wrote 0, left 901 already-correct` is what a node
|
|
285
|
+
* printed while removing 77 files. The number that mattered was the one not
|
|
286
|
+
* on the line.
|
|
287
|
+
*/
|
|
288
|
+
private _restorePruned;
|
|
279
289
|
/** Paths the current {@link restore} could not write because they were held open. */
|
|
280
290
|
private _restoreLocked;
|
|
281
291
|
/**
|
package/dist/fs-agent.js
CHANGED
|
@@ -1152,6 +1152,16 @@ class FsAgent {
|
|
|
1152
1152
|
/** Files written vs left alone by the current {@link restore}. */
|
|
1153
1153
|
_restoreWritten = 0;
|
|
1154
1154
|
_restoreSkipped = 0;
|
|
1155
|
+
/**
|
|
1156
|
+
* Files this restore DELETED.
|
|
1157
|
+
*
|
|
1158
|
+
* Counted and reported because a prune is the only half of a restore that
|
|
1159
|
+
* can destroy anything, and until now it was the only half that happened
|
|
1160
|
+
* silently: `restore: wrote 0, left 901 already-correct` is what a node
|
|
1161
|
+
* printed while removing 77 files. The number that mattered was the one not
|
|
1162
|
+
* on the line.
|
|
1163
|
+
*/
|
|
1164
|
+
_restorePruned = 0;
|
|
1155
1165
|
/** Paths the current {@link restore} could not write because they were held open. */
|
|
1156
1166
|
_restoreLocked = [];
|
|
1157
1167
|
/**
|
|
@@ -1481,6 +1491,7 @@ ${err.stack}` : String(err);
|
|
|
1481
1491
|
const preRestore = options?.cleanTarget ? await this._collectAllFiles(target) : /* @__PURE__ */ new Set();
|
|
1482
1492
|
this._restoreWritten = 0;
|
|
1483
1493
|
this._restoreSkipped = 0;
|
|
1494
|
+
this._restorePruned = 0;
|
|
1484
1495
|
this._restoreLocked = [];
|
|
1485
1496
|
await this._restoreTree(
|
|
1486
1497
|
tree.rootHash,
|
|
@@ -1488,9 +1499,9 @@ ${err.stack}` : String(err);
|
|
|
1488
1499
|
target,
|
|
1489
1500
|
target === this._rootPath
|
|
1490
1501
|
);
|
|
1491
|
-
if (this._restoreSkipped > 0) {
|
|
1502
|
+
if (this._restoreSkipped > 0 || this._restorePruned > 0) {
|
|
1492
1503
|
console.log(
|
|
1493
|
-
`[FsAgent] restore: wrote ${this._restoreWritten}, left ${this._restoreSkipped} already-correct file${this._restoreSkipped === 1 ? "" : "s"} untouched`
|
|
1504
|
+
`[FsAgent] restore: wrote ${this._restoreWritten}, left ${this._restoreSkipped} already-correct file${this._restoreSkipped === 1 ? "" : "s"} untouched` + (this._restorePruned > 0 ? `, DELETED ${this._restorePruned}` : "")
|
|
1494
1505
|
);
|
|
1495
1506
|
}
|
|
1496
1507
|
if (options?.cleanTarget) {
|
|
@@ -1929,6 +1940,7 @@ ${err.stack}` : String(err);
|
|
|
1929
1940
|
}
|
|
1930
1941
|
} else if (!expectedFiles.has(fullPath) && preRestore.has(fullPath)) {
|
|
1931
1942
|
await rm(fullPath, { force: true });
|
|
1943
|
+
this._restorePruned++;
|
|
1932
1944
|
}
|
|
1933
1945
|
}
|
|
1934
1946
|
}
|
|
@@ -2419,10 +2431,10 @@ ${err.stack}` : String(err);
|
|
|
2419
2431
|
`syncFromDb → extract(${this._rootPath})`
|
|
2420
2432
|
);
|
|
2421
2433
|
if (this._treesHaveEquivalentContent(currentTree, incomingTree)) {
|
|
2422
|
-
const
|
|
2434
|
+
const incomingFiles2 = this._getFileContentMap(incomingTree);
|
|
2423
2435
|
const currentFiles = this._getFileContentMap(currentTree);
|
|
2424
2436
|
console.log(
|
|
2425
|
-
`[FsAgent] syncFromDb: equivalent content, skipping restore (incoming=${
|
|
2437
|
+
`[FsAgent] syncFromDb: equivalent content, skipping restore (incoming=${incomingFiles2.size} entries, current=${currentFiles.size} entries, ref=${treeRef.slice(0, 8)}…)`
|
|
2426
2438
|
);
|
|
2427
2439
|
this._adoptAppliedRef(connector, treeRef);
|
|
2428
2440
|
this._currentRef = treeRef;
|
|
@@ -2460,6 +2472,11 @@ ${err.stack}` : String(err);
|
|
|
2460
2472
|
`[FsAgent] ref=${treeRef.slice(0, 8)}… declares no ancestry — applying additively, not pruning.`
|
|
2461
2473
|
);
|
|
2462
2474
|
}
|
|
2475
|
+
if (restoreOptions?.cleanTarget) {
|
|
2476
|
+
console.log(
|
|
2477
|
+
`[FsAgent] applying ref=${treeRef.slice(0, 8)}… newestFromSender=${isNewestFromSender} declaresAncestry=${declaresAncestry} mayPrune=${applyOptions === restoreOptions} incomingFiles=${this._getFileContentMap(incomingTree).size} currentFiles=${this._getFileContentMap(currentTree).size}`
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2463
2480
|
await FsAgent._withTimeout(
|
|
2464
2481
|
this.restore(incomingTree, void 0, applyOptions),
|
|
2465
2482
|
this._timeouts.restore,
|
|
@@ -2479,10 +2496,23 @@ ${err.stack}` : String(err);
|
|
|
2479
2496
|
this._adoptAppliedRef(connector, treeRef);
|
|
2480
2497
|
this._currentRef = postRestoreRef;
|
|
2481
2498
|
this._persistCurrentRef(postRestoreRef);
|
|
2482
|
-
const
|
|
2483
|
-
|
|
2499
|
+
const postRestoreFiles = this._getFileContentMap(postRestoreTree);
|
|
2500
|
+
const incomingFiles = this._getFileContentMap(incomingTree);
|
|
2501
|
+
let hasNewsOfOurOwn = false;
|
|
2502
|
+
for (const path of postRestoreFiles.keys()) {
|
|
2503
|
+
if (!incomingFiles.has(path)) {
|
|
2504
|
+
hasNewsOfOurOwn = true;
|
|
2505
|
+
break;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
if (!hasNewsOfOurOwn) {
|
|
2484
2509
|
this._lastSentRef = postRestoreRef;
|
|
2485
|
-
this._lastSentContentKey =
|
|
2510
|
+
this._lastSentContentKey = this._contentKeyFromTree(postRestoreTree);
|
|
2511
|
+
if (postRestoreFiles.size < incomingFiles.size) {
|
|
2512
|
+
console.log(
|
|
2513
|
+
`[FsAgent] ref=${treeRef.slice(0, 8)}… left this node behind (${postRestoreFiles.size} of ${incomingFiles.size} files) — not announcing a state that is catching up.`
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2486
2516
|
}
|
|
2487
2517
|
return;
|
|
2488
2518
|
} catch (err) {
|