@rljson/fs-agent 0.0.61 → 0.0.62

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.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._shouldIgnore(filename)) {
733
+ if (this._shouldIgnorePath(filename)) {
708
734
  return;
709
735
  }
710
736
  await this._handleFileChange(eventType, filename);
@@ -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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/fs-agent",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "Rljson fs-agent description",
5
5
  "homepage": "https://github.com/rljson/fs-agent",
6
6
  "bugs": "https://github.com/rljson/fs-agent/issues",