Skip to content

Commit 30d92ed

Browse files
committed
Add clear cache support
1 parent eff506f commit 30d92ed

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/client/common/persistentState.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import { cache } from './utils/decorators';
2121
import { noop } from './utils/misc';
2222
import { clearCacheDirectory } from '../pythonEnvironments/base/locators/common/nativePythonFinder';
23+
import { clearCache, useEnvExtension } from '../envExt/api.internal';
2324

2425
let _workspaceState: Memento | undefined;
2526
const _workspaceKeys: string[] = [];
@@ -134,6 +135,9 @@ export class PersistentStateFactory implements IPersistentStateFactory, IExtensi
134135
this.cmdManager?.registerCommand(Commands.ClearStorage, async () => {
135136
await clearWorkspaceState();
136137
await this.cleanAllPersistentStates();
138+
if (useEnvExtension()) {
139+
await clearCache();
140+
}
137141
});
138142
const globalKeysStorageDeprecated = this.createGlobalPersistentState(GLOBAL_PERSISTENT_KEYS_DEPRECATED, []);
139143
const workspaceKeysStorageDeprecated = this.createWorkspacePersistentState(

src/client/envExt/api.internal.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
PythonProcess,
1212
RefreshEnvironmentsScope,
1313
} from './types';
14+
import { executeCommand } from '../common/vscodeApis/commandApis';
1415

1516
export const ENVS_EXTENSION_ID = 'ms-python.vscode-python-envs';
1617

@@ -98,3 +99,10 @@ export async function runInDedicatedTerminal(
9899
}
99100
throw new Error('Invalid arguments to run in dedicated terminal');
100101
}
102+
103+
export async function clearCache(): Promise<void> {
104+
const envExtApi = await getEnvExtApi();
105+
if (envExtApi) {
106+
await executeCommand('python-envs.clearCache');
107+
}
108+
}

0 commit comments

Comments
 (0)