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

fix deleting profiles and clean up default extensions profile #153047

Merged
merged 1 commit into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/vs/platform/userDataProfile/electron-main/userDataProfile.ts
Expand Up @@ -127,14 +127,18 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
});
await Promises.settled(joiners);

if (this.profiles.length === 2) {
await this.fileService.del(this.profilesHome, { recursive: true });
} else {
await this.fileService.del(profile.location, { recursive: true });
}

this.setStoredWorskpaceInfos(this.getStoredWorskpaceInfos().filter(p => !this.uriIdentityService.extUri.isEqual(p.profile, profile.location)));
this.setStoredProfiles(this.getStoredProfiles().filter(p => !this.uriIdentityService.extUri.isEqual(p.location, profile.location)));

try {
if (this.profiles.length === 2) {
await this.fileService.del(this.profilesHome, { recursive: true });
} else {
await this.fileService.del(profile.location, { recursive: true });
}
} catch (error) {
this.logService.error(error);
}
}

private setStoredProfiles(storedProfiles: StoredUserDataProfile[]) {
Expand Down
Expand Up @@ -89,7 +89,11 @@ export class UserDataProfileManagementService extends Disposable implements IUse
if (profile.id === this.userDataProfileService.currentProfile.id) {
throw new Error(localize('cannotDeleteCurrentProfile', "Cannot delete the current profile"));
}
const defaultExtensionsResourceToDelete = this.userDataProfilesService.profiles.length === 2 ? this.userDataProfilesService.defaultProfile.extensionsResource : undefined;
await this.userDataProfilesService.removeProfile(profile);
if (defaultExtensionsResourceToDelete) {
try { await this.fileService.del(defaultExtensionsResourceToDelete); } catch (error) { /* ignore */ }
}
}

async switchProfile(profile: IUserDataProfile): Promise<void> {
Expand Down Expand Up @@ -164,6 +168,7 @@ export class UserDataProfileManagementService extends Disposable implements IUse
}

private async createDefaultExtensionsProfile(extensionsProfileResource: URI): Promise<URI> {
try { await this.fileService.del(extensionsProfileResource); } catch (error) { /* ignore */ }
const extensionManagementService = this.extensionManagementServerService.localExtensionManagementServer?.extensionManagementService ?? this.extensionManagementService;
const userExtensions = await extensionManagementService.getInstalled(ExtensionType.User);
const extensions: [ILocalExtension, Metadata | undefined][] = await Promise.all(userExtensions.map(async e => ([e, await this.extensionManagementService.getMetadata(e)])));
Expand Down