From d3a6a234497b9028b02f20465b9b6d1a0158d2f1 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Tue, 2 Oct 2018 11:39:15 +0200 Subject: [PATCH] Remove synchronization --- .../node/multiExtensionManagement.ts | 96 +------------------ 1 file changed, 1 insertion(+), 95 deletions(-) diff --git a/src/vs/platform/extensionManagement/node/multiExtensionManagement.ts b/src/vs/platform/extensionManagement/node/multiExtensionManagement.ts index 065bac07359..747d5d2af7a 100644 --- a/src/vs/platform/extensionManagement/node/multiExtensionManagement.ts +++ b/src/vs/platform/extensionManagement/node/multiExtensionManagement.ts @@ -5,19 +5,13 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { Event, EventMultiplexer } from 'vs/base/common/event'; -import * as pfs from 'vs/base/node/pfs'; import { IExtensionManagementService, ILocalExtension, IGalleryExtension, LocalExtensionType, InstallExtensionEvent, DidInstallExtensionEvent, IExtensionIdentifier, DidUninstallExtensionEvent, IReportedExtension, IGalleryMetadata, - IExtensionManagementServerService, IExtensionManagementServer, IExtensionGalleryService, InstallOperation + IExtensionManagementServerService, IExtensionManagementServer, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { flatten } from 'vs/base/common/arrays'; import { isWorkspaceExtension, areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { URI } from 'vs/base/common/uri'; -import { INotificationService, Severity, INotificationHandle } from 'vs/platform/notification/common/notification'; -import { localize } from 'vs/nls'; -import { IWindowService } from 'vs/platform/windows/common/windows'; -import { Action } from 'vs/base/common/actions'; -import { ILogService } from 'vs/platform/log/common/log'; import { Disposable } from 'vs/base/common/lifecycle'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { CancellationToken } from 'vs/base/common/cancellation'; @@ -37,9 +31,6 @@ export class MulitExtensionManagementService extends Disposable implements IExte constructor( @IExtensionManagementServerService private extensionManagementServerService: IExtensionManagementServerService, - @INotificationService private notificationService: INotificationService, - @IWindowService private windowService: IWindowService, - @ILogService private logService: ILogService, @IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService, @IConfigurationService private configurationService: IConfigurationService ) { @@ -52,10 +43,6 @@ export class MulitExtensionManagementService extends Disposable implements IExte this.onDidInstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer, server) => { emitter.add(server.extensionManagementService.onDidInstallExtension); return emitter; }, new EventMultiplexer())).event; this.onUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer, server) => { emitter.add(server.extensionManagementService.onUninstallExtension); return emitter; }, new EventMultiplexer())).event; this.onDidUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer, server) => { emitter.add(server.extensionManagementService.onDidUninstallExtension); return emitter; }, new EventMultiplexer())).event; - - if (this.otherServers.length) { - this.syncExtensions(); - } } getInstalled(type?: LocalExtensionType): TPromise { @@ -115,85 +102,4 @@ export class MulitExtensionManagementService extends Disposable implements IExte private getServer(extension: ILocalExtension): IExtensionManagementServer { return this.extensionManagementServerService.getExtensionManagementServer(extension.location); } - - private async syncExtensions(): Promise { - this.localServer.extensionManagementService.getInstalled(LocalExtensionType.User) - .then(async localExtensions => { - const workspaceExtensions = localExtensions.filter(e => isWorkspaceExtension(e.manifest, this.configurationService)); - const extensionsToSync: Map = await this.getExtensionsToSync(workspaceExtensions); - if (extensionsToSync.size > 0) { - const handler = this.notificationService.notify({ severity: Severity.Info, message: localize('synchronising', "Synchronising workspace extensions...") }); - handler.progress.infinite(); - this.doSyncExtensions(extensionsToSync, handler).then(() => { - handler.progress.done(); - handler.updateMessage(localize('Synchronize.finished', "Finished synchronising. Please reload now.")); - handler.updateActions({ - primary: [ - new Action('Synchronize.reloadNow', localize('Synchronize.reloadNow', "Reload Now"), null, true, () => this.windowService.reloadWindow()) - ] - }); - }, error => { - handler.progress.done(); - handler.updateSeverity(Severity.Error); - handler.updateMessage(error); - }); - } - }, err => this.logService.error('Error while Synchronisation', err)); - } - - private async getExtensionsToSync(workspaceExtensions: ILocalExtension[]): Promise> { - const extensionsToSync: Map = new Map(); - for (const server of this.otherServers) { - const extensions = await server.extensionManagementService.getInstalled(LocalExtensionType.User); - const groupedByVersionId: Map = extensions.reduce((groupedById, extension) => groupedById.set(`${extension.galleryIdentifier.id}-${extension.manifest.version}`, extension), new Map()); - const toSync = workspaceExtensions.filter(e => !groupedByVersionId.has(`${e.galleryIdentifier.id}-${e.manifest.version}`)); - if (toSync.length) { - extensionsToSync.set(server, toSync); - } - } - return extensionsToSync; - } - - private async doSyncExtensions(extensionsToSync: Map, notificationHandler: INotificationHandle): Promise { - const ids: string[] = []; - const zipLocationResolvers: TPromise<{ location: URI, vsix: boolean }>[] = []; - - extensionsToSync.forEach(extensions => { - for (const extension of extensions) { - if (ids.indexOf(extension.galleryIdentifier.id) === -1) { - ids.push(extension.galleryIdentifier.id); - zipLocationResolvers.push(this.downloadFromGallery(extension) - .then(location => location ? { location, vsix: true } : this.localServer.extensionManagementService.zip(extension).then(location => ({ location, vsix: false })))); - } - } - }); - - const zipLocations = await TPromise.join(zipLocationResolvers); - const promises: Promise[] = []; - extensionsToSync.forEach((extensions, server) => { - let promise: Promise = Promise.resolve(); - extensions.forEach(extension => { - const index = ids.indexOf(extension.galleryIdentifier.id); - const { location, vsix } = zipLocations[index]; - promise = promise - .then(() => { - notificationHandler.updateMessage(localize('synchronising extension', "Synchronising workspace extension: {0}", extension.manifest.displayName || extension.manifest.name)); - return vsix ? server.extensionManagementService.install(location) : server.extensionManagementService.unzip(location, extension.type); - }).then( - () => pfs.rimraf(location.fsPath), - error => pfs.rimraf(location.fsPath).then(() => TPromise.wrapError(error), () => TPromise.wrapError(error))); - }); - promises.push(promise); - }); - - await Promise.all(promises); - } - - private downloadFromGallery(extension: ILocalExtension): TPromise { - if (this.extensionGalleryService.isEnabled()) { - return this.extensionGalleryService.getExtension(extension.galleryIdentifier, extension.manifest.version) - .then(galleryExtension => galleryExtension ? this.extensionGalleryService.download(galleryExtension, InstallOperation.None).then(location => URI.file(location)) : null); - } - return TPromise.as(null); - } } \ No newline at end of file -- GitLab