fix: support filesystem change notifications for multiple connections

This commit is contained in:
James Murdza
2024-10-25 19:03:13 -06:00
parent eb973e0f83
commit d2ab544582
5 changed files with 103 additions and 72 deletions

View File

@ -50,13 +50,13 @@ export class FileManager {
public fileData: TFileData[]
private fileWatchers: WatchHandle[] = []
private dirName = "/home/user/project"
private refreshFileList: (files: (TFolder | TFile)[]) => void
private refreshFileList: ((files: (TFolder | TFile)[]) => void) | null
// Constructor to initialize the FileManager
constructor(
sandboxId: string,
sandbox: Sandbox,
refreshFileList: (files: (TFolder | TFile)[]) => void
refreshFileList: ((files: (TFolder | TFile)[]) => void) | null
) {
this.sandboxId = sandboxId
this.sandbox = sandbox
@ -314,7 +314,9 @@ export class FileManager {
}
// Tell the client to reload the file list
this.refreshFileList(this.files)
if (event.type !== "chmod") {
this.refreshFileList?.(this.files)
}
} catch (error) {
console.error(
`Error handling ${event.type} event for ${event.name}:`,