|
|
@ -11,6 +11,7 @@ export class RemixdClient extends PluginClient { |
|
|
|
trackDownStreamUpdate: TrackDownStreamUpdate = {} |
|
|
|
trackDownStreamUpdate: TrackDownStreamUpdate = {} |
|
|
|
websocket: WS |
|
|
|
websocket: WS |
|
|
|
currentSharedFolder: string |
|
|
|
currentSharedFolder: string |
|
|
|
|
|
|
|
watcher: chokidar.FSWatcher |
|
|
|
|
|
|
|
|
|
|
|
constructor (private readOnly = false) { |
|
|
|
constructor (private readOnly = false) { |
|
|
|
super() |
|
|
|
super() |
|
|
@ -19,6 +20,9 @@ export class RemixdClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
|
|
setWebSocket (websocket: WS): void { |
|
|
|
setWebSocket (websocket: WS): void { |
|
|
|
this.websocket = websocket |
|
|
|
this.websocket = websocket |
|
|
|
|
|
|
|
this.websocket.addEventListener('close', () => { |
|
|
|
|
|
|
|
if (this.watcher) this.watcher.close() |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sharedFolder (currentSharedFolder: string): void { |
|
|
|
sharedFolder (currentSharedFolder: string): void { |
|
|
@ -246,7 +250,7 @@ export class RemixdClient extends PluginClient { |
|
|
|
const absPath = utils.absolutePath('./', path) |
|
|
|
const absPath = utils.absolutePath('./', path) |
|
|
|
|
|
|
|
|
|
|
|
if (!isRealPath(absPath)) return |
|
|
|
if (!isRealPath(absPath)) return |
|
|
|
const watcher = chokidar.watch(path, { depth: 0, ignorePermissionErrors: true }) |
|
|
|
this.watcher = chokidar.watch(path, { depth: 0, ignorePermissionErrors: true }) |
|
|
|
console.log('setup notifications for ' + path) |
|
|
|
console.log('setup notifications for ' + path) |
|
|
|
/* we can't listen on created file / folder |
|
|
|
/* we can't listen on created file / folder |
|
|
|
watcher.on('add', (f, stat) => { |
|
|
|
watcher.on('add', (f, stat) => { |
|
|
@ -260,7 +264,7 @@ export class RemixdClient extends PluginClient { |
|
|
|
this.emit('created', { path: utils.relativePath(f, this.currentSharedFolder), isReadOnly: false, isFolder: true }) |
|
|
|
this.emit('created', { path: utils.relativePath(f, this.currentSharedFolder), isReadOnly: false, isFolder: true }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
watcher.on('change', async (f: string) => { |
|
|
|
this.watcher.on('change', async (f: string) => { |
|
|
|
if (this.trackDownStreamUpdate[f]) { |
|
|
|
if (this.trackDownStreamUpdate[f]) { |
|
|
|
delete this.trackDownStreamUpdate[f] |
|
|
|
delete this.trackDownStreamUpdate[f] |
|
|
|
return |
|
|
|
return |
|
|
@ -269,12 +273,12 @@ export class RemixdClient extends PluginClient { |
|
|
|
this.emit('changed', utils.relativePath(f, this.currentSharedFolder)) |
|
|
|
this.emit('changed', utils.relativePath(f, this.currentSharedFolder)) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
watcher.on('unlink', async (f: string) => { |
|
|
|
this.watcher.on('unlink', async (f: string) => { |
|
|
|
if (this.isLoaded) { |
|
|
|
if (this.isLoaded) { |
|
|
|
this.emit('removed', utils.relativePath(f, this.currentSharedFolder), false)
|
|
|
|
this.emit('removed', utils.relativePath(f, this.currentSharedFolder), false)
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
watcher.on('unlinkDir', async (f: string) => { |
|
|
|
this.watcher.on('unlinkDir', async (f: string) => { |
|
|
|
if (this.isLoaded) { |
|
|
|
if (this.isLoaded) { |
|
|
|
this.emit('removed', utils.relativePath(f, this.currentSharedFolder), true)
|
|
|
|
this.emit('removed', utils.relativePath(f, this.currentSharedFolder), true)
|
|
|
|
} |
|
|
|
} |
|
|
|