@rljson/fs-agent 0.0.45 → 0.0.47
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 +27 -4
- 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
|
}
|
|
@@ -2425,6 +2437,9 @@ ${err.stack}` : String(err);
|
|
|
2425
2437
|
`[FsAgent] syncFromDb: equivalent content, skipping restore (incoming=${incomingFiles.size} entries, current=${currentFiles.size} entries, ref=${treeRef.slice(0, 8)}…)`
|
|
2426
2438
|
);
|
|
2427
2439
|
this._adoptAppliedRef(connector, treeRef);
|
|
2440
|
+
this._currentRef = treeRef;
|
|
2441
|
+
this._persistCurrentRef(treeRef);
|
|
2442
|
+
this._lastSentContentKey = this._contentKeyFromTree(currentTree);
|
|
2428
2443
|
return;
|
|
2429
2444
|
}
|
|
2430
2445
|
if (this._resolveConflicts && this._currentRef && predecessorRefs && predecessorRefs.length > 0) {
|
|
@@ -2457,6 +2472,11 @@ ${err.stack}` : String(err);
|
|
|
2457
2472
|
`[FsAgent] ref=${treeRef.slice(0, 8)}… declares no ancestry — applying additively, not pruning.`
|
|
2458
2473
|
);
|
|
2459
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
|
+
}
|
|
2460
2480
|
await FsAgent._withTimeout(
|
|
2461
2481
|
this.restore(incomingTree, void 0, applyOptions),
|
|
2462
2482
|
this._timeouts.restore,
|
|
@@ -2474,10 +2494,13 @@ ${err.stack}` : String(err);
|
|
|
2474
2494
|
previous
|
|
2475
2495
|
});
|
|
2476
2496
|
this._adoptAppliedRef(connector, treeRef);
|
|
2477
|
-
this._lastSentRef = postRestoreRef;
|
|
2478
|
-
this._lastSentContentKey = this._contentKeyFromTree(postRestoreTree);
|
|
2479
2497
|
this._currentRef = postRestoreRef;
|
|
2480
2498
|
this._persistCurrentRef(postRestoreRef);
|
|
2499
|
+
const postRestoreKey = this._contentKeyFromTree(postRestoreTree);
|
|
2500
|
+
if (postRestoreKey === this._contentKeyFromTree(incomingTree)) {
|
|
2501
|
+
this._lastSentRef = postRestoreRef;
|
|
2502
|
+
this._lastSentContentKey = postRestoreKey;
|
|
2503
|
+
}
|
|
2481
2504
|
return;
|
|
2482
2505
|
} catch (err) {
|
|
2483
2506
|
if (err instanceof MassDeleteRefusedError) {
|