@rljson/fs-agent 0.0.61 → 0.0.63
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 +0 -10
- package/dist/fs-agent.js +27 -16
- package/dist/fs-scanner.d.ts +21 -0
- package/package.json +1 -1
package/dist/fs-agent.d.ts
CHANGED
|
@@ -793,16 +793,6 @@ export declare class FsAgent {
|
|
|
793
793
|
* @returns True when every declared parent is a state this node has left.
|
|
794
794
|
*/
|
|
795
795
|
private _senderIsBehind;
|
|
796
|
-
/**
|
|
797
|
-
* Marks an incoming tree's files as known to the network.
|
|
798
|
-
*
|
|
799
|
-
* A union, not a replacement: {@link _rememberAnnounced} answers "what this
|
|
800
|
-
* node has told the network", and this answers "what the network has told
|
|
801
|
-
* this node". Both make a file prunable; neither alone is the whole set, and
|
|
802
|
-
* treating the first as the whole set is what made deletions vanish.
|
|
803
|
-
* @param tree - The tree just applied.
|
|
804
|
-
*/
|
|
805
|
-
private _rememberReceived;
|
|
806
796
|
private _rememberAnnounced;
|
|
807
797
|
private _adoptAppliedRef;
|
|
808
798
|
/**
|
package/dist/fs-agent.js
CHANGED
|
@@ -684,6 +684,32 @@ class FsScanner {
|
|
|
684
684
|
} catch {
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Whether a watcher event's path should be ignored.
|
|
689
|
+
*
|
|
690
|
+
* `fs.watch` in recursive mode reports a path RELATIVE TO THE ROOT
|
|
691
|
+
* (`sub/dir/.fsagent-tmp-abc`), while the ignore patterns are basenames.
|
|
692
|
+
* {@link _shouldIgnore} tests `startsWith`, so a nested match never fired:
|
|
693
|
+
* every atomic write the agent itself makes during a restore came back as a
|
|
694
|
+
* change event, each event triggered a scan, and the debounce that batches a
|
|
695
|
+
* push was reset before it could fire.
|
|
696
|
+
*
|
|
697
|
+
* Measured on the customer's folder: after a 3 642-file restore the watcher
|
|
698
|
+
* reported the SAME newly added file nine times and the agent never emitted a
|
|
699
|
+
* ref for it — `[fs] added: …/probe-….txt` nine times, no `sync:out`. The
|
|
700
|
+
* file did not fail to arrive; it was never sent.
|
|
701
|
+
*
|
|
702
|
+
* Every segment is tested, because the pattern may match a directory as
|
|
703
|
+
* easily as a file.
|
|
704
|
+
* @param relativePath - Path as the watcher reports it.
|
|
705
|
+
* @returns True when any segment matches an ignore pattern.
|
|
706
|
+
*/
|
|
707
|
+
_shouldIgnorePath(relativePath) {
|
|
708
|
+
for (const segment of relativePath.split(/[\\/]/)) {
|
|
709
|
+
if (segment && this._shouldIgnore(segment)) return true;
|
|
710
|
+
}
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
687
713
|
_shouldIgnore(name) {
|
|
688
714
|
if (!this._options.ignore) {
|
|
689
715
|
return false;
|
|
@@ -704,7 +730,7 @@ class FsScanner {
|
|
|
704
730
|
}
|
|
705
731
|
const onEvent = async (eventType, filename) => {
|
|
706
732
|
if (!filename) return;
|
|
707
|
-
if (this.
|
|
733
|
+
if (this._shouldIgnorePath(filename)) {
|
|
708
734
|
return;
|
|
709
735
|
}
|
|
710
736
|
await this._handleFileChange(eventType, filename);
|
|
@@ -2428,20 +2454,6 @@ ${err.stack}` : String(err);
|
|
|
2428
2454
|
(ref) => ref !== this._currentRef && ref !== this._lastAppliedRef && this._stateHistory.includes(ref)
|
|
2429
2455
|
);
|
|
2430
2456
|
}
|
|
2431
|
-
/**
|
|
2432
|
-
* Marks an incoming tree's files as known to the network.
|
|
2433
|
-
*
|
|
2434
|
-
* A union, not a replacement: {@link _rememberAnnounced} answers "what this
|
|
2435
|
-
* node has told the network", and this answers "what the network has told
|
|
2436
|
-
* this node". Both make a file prunable; neither alone is the whole set, and
|
|
2437
|
-
* treating the first as the whole set is what made deletions vanish.
|
|
2438
|
-
* @param tree - The tree just applied.
|
|
2439
|
-
*/
|
|
2440
|
-
_rememberReceived(tree) {
|
|
2441
|
-
for (const path of this._getFileContentMap(tree).keys()) {
|
|
2442
|
-
this._announcedFiles.add(join(this._rootPath, path));
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
2457
|
_rememberAnnounced(tree) {
|
|
2446
2458
|
this._announcedFiles.clear();
|
|
2447
2459
|
for (const path of this._getFileContentMap(tree).keys()) {
|
|
@@ -2651,7 +2663,6 @@ ${err.stack}` : String(err);
|
|
|
2651
2663
|
this._adoptAppliedRef(connector, treeRef);
|
|
2652
2664
|
this._currentRef = postRestoreRef;
|
|
2653
2665
|
this._persistCurrentRef(postRestoreRef);
|
|
2654
|
-
this._rememberReceived(incomingTree);
|
|
2655
2666
|
const postRestoreFiles = this._getFileContentMap(postRestoreTree);
|
|
2656
2667
|
const incomingFiles = this._getFileContentMap(incomingTree);
|
|
2657
2668
|
let hasNewsOfOurOwn = false;
|
package/dist/fs-scanner.d.ts
CHANGED
|
@@ -141,6 +141,27 @@ export declare class FsScanner {
|
|
|
141
141
|
* (temp + rename). Best-effort: a failed cache write never fails the scan.
|
|
142
142
|
*/
|
|
143
143
|
private _persistCache;
|
|
144
|
+
/**
|
|
145
|
+
* Whether a watcher event's path should be ignored.
|
|
146
|
+
*
|
|
147
|
+
* `fs.watch` in recursive mode reports a path RELATIVE TO THE ROOT
|
|
148
|
+
* (`sub/dir/.fsagent-tmp-abc`), while the ignore patterns are basenames.
|
|
149
|
+
* {@link _shouldIgnore} tests `startsWith`, so a nested match never fired:
|
|
150
|
+
* every atomic write the agent itself makes during a restore came back as a
|
|
151
|
+
* change event, each event triggered a scan, and the debounce that batches a
|
|
152
|
+
* push was reset before it could fire.
|
|
153
|
+
*
|
|
154
|
+
* Measured on the customer's folder: after a 3 642-file restore the watcher
|
|
155
|
+
* reported the SAME newly added file nine times and the agent never emitted a
|
|
156
|
+
* ref for it — `[fs] added: …/probe-….txt` nine times, no `sync:out`. The
|
|
157
|
+
* file did not fail to arrive; it was never sent.
|
|
158
|
+
*
|
|
159
|
+
* Every segment is tested, because the pattern may match a directory as
|
|
160
|
+
* easily as a file.
|
|
161
|
+
* @param relativePath - Path as the watcher reports it.
|
|
162
|
+
* @returns True when any segment matches an ignore pattern.
|
|
163
|
+
*/
|
|
164
|
+
private _shouldIgnorePath;
|
|
144
165
|
private _shouldIgnore;
|
|
145
166
|
watch(): Promise<void>;
|
|
146
167
|
/**
|