@@ -11,7 +11,7 @@ import {
1111} from '../../api' ;
1212import { ENVS_EXTENSION_ID } from '../../common/constants' ;
1313import { traceError , traceInfo } from '../../common/logging' ;
14- import { getGlobalPersistentState , getWorkspacePersistentState } from '../../common/persistentState' ;
14+ import { getWorkspacePersistentState } from '../../common/persistentState' ;
1515import { getUserHomeDir , untildify } from '../../common/utils/pathUtils' ;
1616import { isWindows } from '../../common/utils/platformUtils' ;
1717import { ShellConstants } from '../../features/common/shellConstants' ;
@@ -43,36 +43,28 @@ let poetryPath: string | undefined;
4343let poetryVirtualenvsPath : string | undefined ;
4444
4545export async function clearPoetryCache ( ) : Promise < void > {
46- // Clear workspace-specific settings
47- const state = await getWorkspacePersistentState ( ) ;
48- await state . clear ( [ POETRY_WORKSPACE_KEY ] ) ;
49-
50- // Clear global settings
51- const global = await getGlobalPersistentState ( ) ;
52- await global . clear ( [ POETRY_PATH_KEY , POETRY_GLOBAL_KEY , POETRY_VIRTUALENVS_PATH_KEY ] ) ;
53-
5446 // Reset in-memory cache
5547 poetryPath = undefined ;
5648 poetryVirtualenvsPath = undefined ;
5749}
5850
5951async function setPoetry ( poetry : string ) : Promise < void > {
6052 poetryPath = poetry ;
61- const global = await getGlobalPersistentState ( ) ;
62- await global . set ( POETRY_PATH_KEY , poetry ) ;
53+ const state = await getWorkspacePersistentState ( ) ;
54+ await state . set ( POETRY_PATH_KEY , poetry ) ;
6355
6456 // Also get and cache the virtualenvs path
6557 await getPoetryVirtualenvsPath ( poetry ) ;
6658}
6759
6860export async function getPoetryForGlobal ( ) : Promise < string | undefined > {
69- const global = await getGlobalPersistentState ( ) ;
70- return await global . get ( POETRY_GLOBAL_KEY ) ;
61+ const state = await getWorkspacePersistentState ( ) ;
62+ return await state . get ( POETRY_GLOBAL_KEY ) ;
7163}
7264
7365export async function setPoetryForGlobal ( poetryPath : string | undefined ) : Promise < void > {
74- const global = await getGlobalPersistentState ( ) ;
75- await global . set ( POETRY_GLOBAL_KEY , poetryPath ) ;
66+ const state = await getWorkspacePersistentState ( ) ;
67+ await state . set ( POETRY_GLOBAL_KEY , poetryPath ) ;
7668}
7769
7870export async function getPoetryForWorkspace ( fsPath : string ) : Promise < string | undefined > {
@@ -117,8 +109,8 @@ export async function getPoetry(native?: NativePythonFinder): Promise<string | u
117109 return poetryPath ;
118110 }
119111
120- const global = await getGlobalPersistentState ( ) ;
121- poetryPath = await global . get < string > ( POETRY_PATH_KEY ) ;
112+ const state = await getWorkspacePersistentState ( ) ;
113+ poetryPath = await state . get < string > ( POETRY_PATH_KEY ) ;
122114 if ( poetryPath ) {
123115 traceInfo ( `Using poetry from persistent state: ${ poetryPath } ` ) ;
124116 // Also retrieve the virtualenvs path if we haven't already
@@ -174,8 +166,8 @@ export async function getPoetryVirtualenvsPath(poetryExe?: string): Promise<stri
174166 }
175167
176168 // Check if we have it in persistent state
177- const global = await getGlobalPersistentState ( ) ;
178- poetryVirtualenvsPath = await global . get < string > ( POETRY_VIRTUALENVS_PATH_KEY ) ;
169+ const state = await getWorkspacePersistentState ( ) ;
170+ poetryVirtualenvsPath = await state . get < string > ( POETRY_VIRTUALENVS_PATH_KEY ) ;
179171 if ( poetryVirtualenvsPath ) {
180172 return untildify ( poetryVirtualenvsPath ) ;
181173 }
@@ -199,7 +191,7 @@ export async function getPoetryVirtualenvsPath(poetryExe?: string): Promise<stri
199191 }
200192
201193 if ( poetryVirtualenvsPath ) {
202- await global . set ( POETRY_VIRTUALENVS_PATH_KEY , poetryVirtualenvsPath ) ;
194+ await state . set ( POETRY_VIRTUALENVS_PATH_KEY , poetryVirtualenvsPath ) ;
203195 return poetryVirtualenvsPath ;
204196 }
205197 }
@@ -212,7 +204,7 @@ export async function getPoetryVirtualenvsPath(poetryExe?: string): Promise<stri
212204 const home = getUserHomeDir ( ) ;
213205 if ( home ) {
214206 poetryVirtualenvsPath = path . join ( home , '.cache' , 'pypoetry' , 'virtualenvs' ) ;
215- await global . set ( POETRY_VIRTUALENVS_PATH_KEY , poetryVirtualenvsPath ) ;
207+ await state . set ( POETRY_VIRTUALENVS_PATH_KEY , poetryVirtualenvsPath ) ;
216208 return poetryVirtualenvsPath ;
217209 }
218210
0 commit comments