Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not remove envs which are provided by the consumer #20424

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,20 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
if (envs && isCompleteList) {
/**
* Only consider a cached env to be valid if it's relevant. That means:
* * It is either reported in the latest complete refresh for this session.
* * Or it is relevant for some other workspace folder which is not opened currently.
* * It is relevant for some other workspace folder which is not opened currently.
* * It is either reported in the latest complete discovery for this session.
* * It is provided by the consumer themselves.
*/
if (cachedEnv.searchLocation) {
return true;
}
if (envs.some((env) => cachedEnv.id === env.id)) {
return true;
}
if (Array.from(this.validatedEnvs.keys()).some((envId) => cachedEnv.id === envId)) {
// These envs are provided by the consumer themselves, consider them valid.
return true;
}
} else {
return true;
}
Expand Down Expand Up @@ -141,7 +146,7 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
public addEnv(env: PythonEnvInfo, hasLatestInfo?: boolean): void {
const found = this.envs.find((e) => areSameEnv(e, env));
if (hasLatestInfo) {
traceVerbose(`Adding env to cache ${env.id}`);
traceVerbose(`Flushing env to cache ${env.id}`);
this.validatedEnvs.add(env.id!);
this.flush(env).ignoreErrors(); // If we have latest info, flush it so it can be saved.
}
Expand Down