-
Notifications
You must be signed in to change notification settings - Fork 29k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#140088 - extension storage migration support while migrating to pre-…
…releases
- Loading branch information
Showing
10 changed files
with
123 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/vs/platform/extensionManagement/common/unsupportedExtensionsMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { IExtensionGalleryService, IExtensionManagementService, IGlobalExtensionEnablementService, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement'; | ||
import { areSameExtensions, getExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; | ||
import { IExtensionStorageService } from 'vs/platform/extensionManagement/common/extensionStorage'; | ||
import { ExtensionType } from 'vs/platform/extensions/common/extensions'; | ||
import { ILogService } from 'vs/platform/log/common/log'; | ||
|
||
/** | ||
* Migrates the installed unsupported nightly extension to a supported pre-release extension. It includes following: | ||
* - Uninstall the Unsupported extension | ||
* - Install (with optional storage migration) the Pre-release extension only if | ||
* - the extension is not installed | ||
* - or it is a release version and the unsupported extension is enabled. | ||
*/ | ||
export async function migrateUnsupportedExtensions(extensionManagementService: IExtensionManagementService, galleryService: IExtensionGalleryService, extensionStorageService: IExtensionStorageService, extensionEnablementService: IGlobalExtensionEnablementService, logService: ILogService): Promise<void> { | ||
try { | ||
const extensionsControlManifest = await extensionManagementService.getExtensionsControlManifest(); | ||
if (!extensionsControlManifest.unsupportedPreReleaseExtensions) { | ||
return; | ||
} | ||
const installed = await extensionManagementService.getInstalled(ExtensionType.User); | ||
for (const [unsupportedExtensionId, { id: preReleaseExtensionId, migrateStorage }] of Object.entries(extensionsControlManifest.unsupportedPreReleaseExtensions)) { | ||
const unsupportedExtension = installed.find(i => areSameExtensions(i.identifier, { id: unsupportedExtensionId })); | ||
// Unsupported Extension is not installed | ||
if (!unsupportedExtension) { | ||
continue; | ||
} | ||
|
||
const gallery = await galleryService.getCompatibleExtension({ id: preReleaseExtensionId }, true, await extensionManagementService.getTargetPlatform()); | ||
if (!gallery) { | ||
logService.info(`Skipping migrating '${unsupportedExtension.identifier.id}' extension because, the comaptible target '${preReleaseExtensionId}' extension is not found`); | ||
continue; | ||
} | ||
|
||
try { | ||
logService.info(`Migrating '${unsupportedExtension.identifier.id}' extension to '${preReleaseExtensionId}' extension...`); | ||
|
||
const isUnsupportedExtensionEnabled = !extensionEnablementService.getDisabledExtensions().some(e => areSameExtensions(e, unsupportedExtension.identifier)); | ||
await extensionManagementService.uninstall(unsupportedExtension); | ||
logService.info(`Uninstalled the unsupported extension '${unsupportedExtension.identifier.id}'`); | ||
|
||
let preReleaseExtension = installed.find(i => areSameExtensions(i.identifier, { id: preReleaseExtensionId })); | ||
if (!preReleaseExtension || (!preReleaseExtension.isPreReleaseVersion && isUnsupportedExtensionEnabled)) { | ||
preReleaseExtension = await extensionManagementService.installFromGallery(gallery, { installPreReleaseVersion: true, isMachineScoped: unsupportedExtension.isMachineScoped, operation: InstallOperation.Migrate }); | ||
logService.info(`Installed the pre-release extension '${preReleaseExtension.identifier.id}'`); | ||
if (!isUnsupportedExtensionEnabled) { | ||
await extensionEnablementService.disableExtension(preReleaseExtension.identifier); | ||
logService.info(`Disabled the pre-release extension '${preReleaseExtension.identifier.id}' because the unsupported extension '${unsupportedExtension.identifier.id}' is disabled`); | ||
} | ||
if (migrateStorage) { | ||
extensionStorageService.addToMigrationList(getExtensionId(unsupportedExtension.manifest.publisher, unsupportedExtension.manifest.name), getExtensionId(preReleaseExtension.manifest.publisher, preReleaseExtension.manifest.name)); | ||
logService.info(`Added pre-release extension to the storage migration list`); | ||
} | ||
} | ||
logService.info(`Migrated '${unsupportedExtension.identifier.id}' extension to '${preReleaseExtensionId}' extension.`); | ||
} catch (error) { | ||
logService.error(error); | ||
} | ||
} | ||
} catch (error) { | ||
logService.error(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/vs/workbench/contrib/extensions/browser/unsupportedExtensionsMigrationContribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement'; | ||
import { IExtensionStorageService } from 'vs/platform/extensionManagement/common/extensionStorage'; | ||
import { migrateUnsupportedExtensions } from 'vs/platform/extensionManagement/common/unsupportedExtensionsMigration'; | ||
import { ILogService } from 'vs/platform/log/common/log'; | ||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; | ||
import { IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; | ||
|
||
export class UnsupportedExtensionsMigrationContrib implements IWorkbenchContribution { | ||
|
||
constructor( | ||
@IExtensionManagementServerService extensionManagementServerService: IExtensionManagementServerService, | ||
@IExtensionGalleryService extensionGalleryService: IExtensionGalleryService, | ||
@IExtensionStorageService extensionStorageService: IExtensionStorageService, | ||
@IGlobalExtensionEnablementService extensionEnablementService: IGlobalExtensionEnablementService, | ||
@ILogService logService: ILogService, | ||
) { | ||
// Unsupported extensions are not migrated for local extension management server, because it is done in shared process | ||
if (extensionManagementServerService.remoteExtensionManagementServer) { | ||
migrateUnsupportedExtensions(extensionManagementServerService.remoteExtensionManagementServer.extensionManagementService, extensionGalleryService, extensionStorageService, extensionEnablementService, logService); | ||
} | ||
if (extensionManagementServerService.webExtensionManagementServer) { | ||
migrateUnsupportedExtensions(extensionManagementServerService.webExtensionManagementServer.extensionManagementService, extensionGalleryService, extensionStorageService, extensionEnablementService, logService); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters