@rljson/fs-agent 0.0.10 → 0.0.11
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 +25 -1
- package/dist/fs-scanner.d.ts +9 -1
- package/package.json +1 -1
package/dist/fs-agent.js
CHANGED
|
@@ -178,6 +178,7 @@ class FsScanner {
|
|
|
178
178
|
_options;
|
|
179
179
|
_bs;
|
|
180
180
|
_paused = false;
|
|
181
|
+
_missedChangesDuringPause = false;
|
|
181
182
|
constructor(rootPath, options = {}) {
|
|
182
183
|
this._rootPath = rootPath;
|
|
183
184
|
this._options = {
|
|
@@ -365,6 +366,7 @@ class FsScanner {
|
|
|
365
366
|
}
|
|
366
367
|
async _handleFileChange(_eventType, filename) {
|
|
367
368
|
if (this._paused) {
|
|
369
|
+
this._missedChangesDuringPause = true;
|
|
368
370
|
return;
|
|
369
371
|
}
|
|
370
372
|
const relativePath = filename.replace(/\\/g, "/");
|
|
@@ -442,12 +444,34 @@ class FsScanner {
|
|
|
442
444
|
*/
|
|
443
445
|
pauseWatch() {
|
|
444
446
|
this._paused = true;
|
|
447
|
+
this._missedChangesDuringPause = false;
|
|
445
448
|
}
|
|
446
449
|
/**
|
|
447
|
-
* Resume file change notifications
|
|
450
|
+
* Resume file change notifications.
|
|
451
|
+
* If any filesystem events were missed during the pause, triggers
|
|
452
|
+
* an asynchronous rescan so that syncToDb can detect and push the changes.
|
|
448
453
|
*/
|
|
449
454
|
resumeWatch() {
|
|
455
|
+
const missedChanges = this._missedChangesDuringPause;
|
|
450
456
|
this._paused = false;
|
|
457
|
+
this._missedChangesDuringPause = false;
|
|
458
|
+
if (missedChanges) {
|
|
459
|
+
void this._rescanAfterPause();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Re-scan the filesystem and fire onChange callbacks to catch modifications
|
|
464
|
+
* that were missed while watching was paused.
|
|
465
|
+
*/
|
|
466
|
+
async _rescanAfterPause() {
|
|
467
|
+
try {
|
|
468
|
+
await this.scan();
|
|
469
|
+
if (this._paused) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
await this._notifyChange({ type: "modified", path: "." });
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
451
475
|
}
|
|
452
476
|
getTreeByHash(treeHash) {
|
|
453
477
|
return this._tree?.trees.get(treeHash);
|
package/dist/fs-scanner.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare class FsScanner {
|
|
|
72
72
|
private _options;
|
|
73
73
|
private _bs;
|
|
74
74
|
private _paused;
|
|
75
|
+
private _missedChangesDuringPause;
|
|
75
76
|
constructor(rootPath: string, options?: FsScanOptions);
|
|
76
77
|
get tree(): FsTree | null;
|
|
77
78
|
get rootPath(): string;
|
|
@@ -92,9 +93,16 @@ export declare class FsScanner {
|
|
|
92
93
|
*/
|
|
93
94
|
pauseWatch(): void;
|
|
94
95
|
/**
|
|
95
|
-
* Resume file change notifications
|
|
96
|
+
* Resume file change notifications.
|
|
97
|
+
* If any filesystem events were missed during the pause, triggers
|
|
98
|
+
* an asynchronous rescan so that syncToDb can detect and push the changes.
|
|
96
99
|
*/
|
|
97
100
|
resumeWatch(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Re-scan the filesystem and fire onChange callbacks to catch modifications
|
|
103
|
+
* that were missed while watching was paused.
|
|
104
|
+
*/
|
|
105
|
+
private _rescanAfterPause;
|
|
98
106
|
getTreeByHash(treeHash: TreeRef): Tree | undefined;
|
|
99
107
|
getTreeByPath(relativePath: string): Tree | undefined;
|
|
100
108
|
getAllTrees(): Tree[];
|