@@ -36,10 +36,10 @@ export interface IEnvsCollectionCache {
3636 addEnv ( env : PythonEnvInfo ) : void ;
3737
3838 /**
39- * Return cached environment information for a given interpreter path if it exists,
40- * otherwise return `undefined`.
39+ * Return cached environment information for a given interpreter path if it exists and
40+ * has complete info, otherwise return `undefined`.
4141 */
42- getEnv ( path : string ) : PythonEnvInfo | undefined ;
42+ getCompleteInfo ( path : string ) : PythonEnvInfo | undefined ;
4343
4444 /**
4545 * Writes the content of the in-memory cache to persistent storage.
@@ -53,6 +53,8 @@ export interface IEnvsCollectionCache {
5353 validateCache ( ) : Promise < void > ;
5454}
5555
56+ type PythonEnvCompleteInfo = { hasCompleteInfo ?: boolean } & PythonEnvInfo ;
57+
5658interface IPersistentStorage {
5759 load ( ) : Promise < PythonEnvInfo [ ] | undefined > ;
5860 store ( envs : PythonEnvInfo [ ] ) : Promise < void > ;
@@ -63,7 +65,7 @@ interface IPersistentStorage {
6365 */
6466export class PythonEnvInfoCache extends PythonEnvsWatcher < PythonEnvCollectionChangedEvent >
6567 implements IEnvsCollectionCache {
66- private envs : PythonEnvInfo [ ] = [ ] ;
68+ private envs : PythonEnvCompleteInfo [ ] = [ ] ;
6769
6870 constructor ( private readonly persistentStorage : IPersistentStorage ) {
6971 super ( ) ;
@@ -103,8 +105,9 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
103105 }
104106 }
105107
106- public getEnv ( executablePath : string ) : PythonEnvInfo | undefined {
107- return this . envs . find ( ( e ) => areSameEnv ( e , executablePath ) ) ;
108+ public getCompleteInfo ( executablePath : string ) : PythonEnvInfo | undefined {
109+ const env = this . envs . find ( ( e ) => areSameEnv ( e , executablePath ) ) ;
110+ return env ?. hasCompleteInfo ? env : undefined ;
108111 }
109112
110113 public async clearAndReloadFromStorage ( ) : Promise < void > {
@@ -114,6 +117,9 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
114117 public async flush ( ) : Promise < void > {
115118 if ( this . envs . length ) {
116119 traceInfo ( 'Environments added to cache' , JSON . stringify ( this . envs ) ) ;
120+ this . envs . forEach ( ( e ) => {
121+ e . hasCompleteInfo = true ;
122+ } ) ;
117123 await this . persistentStorage . store ( this . envs ) ;
118124 }
119125 }
0 commit comments