fix: extension fs.watch accepts all event types + debounce (Windows compatibility)
This commit is contained in:
@@ -75,9 +75,12 @@ function startBridge() {
|
||||
|
||||
// Watch bridge/response/ for Discord user responses
|
||||
const responsePath = path.join(bridgePath, 'response');
|
||||
const processedFiles = new Set<string>(); // Debounce: prevent double-processing
|
||||
try {
|
||||
watcher = fs.watch(responsePath, { persistent: false }, (eventType, filename) => {
|
||||
if (eventType === 'rename' && filename && filename.endsWith('.json')) {
|
||||
if (filename && filename.endsWith('.json') && !processedFiles.has(filename)) {
|
||||
processedFiles.add(filename);
|
||||
setTimeout(() => processedFiles.delete(filename), 2000);
|
||||
handleResponse(path.join(responsePath, filename));
|
||||
}
|
||||
});
|
||||
@@ -90,7 +93,9 @@ function startBridge() {
|
||||
const commandsPath = path.join(bridgePath, 'commands');
|
||||
try {
|
||||
fs.watch(commandsPath, { persistent: false }, (eventType, filename) => {
|
||||
if (eventType === 'rename' && filename && filename.endsWith('.json')) {
|
||||
if (filename && filename.endsWith('.json') && !processedFiles.has(filename)) {
|
||||
processedFiles.add(filename);
|
||||
setTimeout(() => processedFiles.delete(filename), 2000);
|
||||
handleCommand(path.join(commandsPath, filename));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user