Skip to content

Commit f624331

Browse files
author
Kartik Raj
authored
Clear duplicated environments from storage (#23076)
Closes #22988 closes #23070 Changes Python environments cache key
1 parent b8d6a2c commit f624331

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/client/pythonEnvironments/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import { traceError } from '../logging';
3939
import { ActiveStateLocator } from './base/locators/lowLevel/activeStateLocator';
4040
import { CustomWorkspaceLocator } from './base/locators/lowLevel/customWorkspaceLocator';
4141

42+
const PYTHON_ENV_INFO_CACHE_KEY = 'PYTHON_ENV_INFO_CACHEv2';
43+
4244
/**
4345
* Set up the Python environments component (during extension activation).'
4446
*/
@@ -68,7 +70,7 @@ export async function activate(api: IDiscoveryAPI, ext: ExtensionState): Promise
6870
*/
6971
const folders = vscode.workspace.workspaceFolders;
7072
// Trigger discovery if environment cache is empty.
71-
const wasTriggered = getGlobalStorage<PythonEnvInfo[]>(ext.context, 'PYTHON_ENV_INFO_CACHE', []).get().length > 0;
73+
const wasTriggered = getGlobalStorage<PythonEnvInfo[]>(ext.context, PYTHON_ENV_INFO_CACHE_KEY, []).get().length > 0;
7274
if (!wasTriggered) {
7375
api.triggerRefresh().ignoreErrors();
7476
folders?.forEach(async (folder) => {
@@ -225,7 +227,7 @@ function putIntoStorage(storage: IPersistentStorage<PythonEnvInfo[]>, envs: Pyth
225227
}
226228

227229
async function createCollectionCache(ext: ExtensionState): Promise<IEnvsCollectionCache> {
228-
const storage = getGlobalStorage<PythonEnvInfo[]>(ext.context, 'PYTHON_ENV_INFO_CACHE', []);
230+
const storage = getGlobalStorage<PythonEnvInfo[]>(ext.context, PYTHON_ENV_INFO_CACHE_KEY, []);
229231
const cache = await createCache({
230232
get: () => getFromStorage(storage),
231233
store: async (e) => putIntoStorage(storage, e),

0 commit comments

Comments
 (0)