fix: Dispose the kubeconfig watcher when application quits

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen committed 2023-04-05 13:34:45 +03:00
1 parent 673144ae8f
commit d0116b3b62
1 file changed
+9 -1
@@ -98,11 +98,19 @@ export class KubeconfigSyncManager {
@action @action
protected stopOldSync(filePath: string): void { protected stopOldSync(filePath: string): void {
if (!this.sources.delete(filePath)) { const source = this.sources.get(filePath);
// already stopped // already stopped
if (!source) {
return this.dependencies.logger.debug(`no syncing file/folder to stop`, { filePath }); return this.dependencies.logger.debug(`no syncing file/folder to stop`, { filePath });
} }
const [, disposer] = source;
disposer();
this.sources.delete(filePath);
this.dependencies.logger.info(`stopping sync of file/folder`, { filePath }); this.dependencies.logger.info(`stopping sync of file/folder`, { filePath });
this.dependencies.logger.debug(`${this.sources.size} files/folders watched`, { files: Array.from(this.sources.keys()) }); this.dependencies.logger.debug(`${this.sources.size} files/folders watched`, { files: Array.from(this.sources.keys()) });
} }