Skip to content

Commit 69f5d2c

Browse files
committed
Cleanup model editor query dir after use
1 parent 4d4a72b commit 69f5d2c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

extensions/ql-vscode/src/model-editor/model-editor-module.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ export class ModelEditorModule extends DisposableObject {
136136
});
137137

138138
// Create new temporary directory for query files and pack dependencies
139-
const queryDir = (await dir({ unsafeCleanup: true })).path;
139+
const { path: queryDir, cleanup: cleanupQueryDir } = await dir({
140+
unsafeCleanup: true,
141+
});
140142
const success = await setUpPack(this.cliServer, queryDir, language);
141143
if (!success) {
144+
await cleanupQueryDir();
142145
return;
143146
}
144147

@@ -161,9 +164,20 @@ export class ModelEditorModule extends DisposableObject {
161164
this.methodsUsagePanel.setState.bind(this.methodsUsagePanel),
162165
this.showMethod.bind(this),
163166
this.handleViewBecameActive.bind(this),
164-
this.handleViewWasDisposed.bind(this),
167+
(view) => {
168+
this.handleViewWasDisposed(view);
169+
void cleanupQueryDir();
170+
},
165171
this.isMostRecentlyActiveView.bind(this),
166172
);
173+
174+
this.push(view);
175+
this.push({
176+
dispose(): void {
177+
void cleanupQueryDir();
178+
},
179+
});
180+
167181
await view.openView();
168182
},
169183
{

0 commit comments

Comments
 (0)