Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae

This commit is contained in:
ADS Merger
2020-06-18 04:32:54 +00:00
committed by AzureDataStudio
parent a971aee5bd
commit 5e7071e466
1002 changed files with 24201 additions and 13193 deletions

View File

@@ -3,7 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { tmpdir } from 'os';
import { Disposable } from 'vs/base/common/lifecycle';
import { IFileService, IFileStatWithMetadata } from 'vs/platform/files/common/files';
import { IExtensionGalleryService, IGalleryExtension, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
@@ -20,9 +19,9 @@ const ExtensionIdVersionRegex = /^([^.]+\..+)-(\d+\.\d+\.\d+)$/;
export class ExtensionsDownloader extends Disposable {
private readonly extensionsDownloadDir: URI = URI.file(tmpdir());
private readonly cache: number = 0;
private readonly cleanUpPromise: Promise<void> = Promise.resolve();
private readonly extensionsDownloadDir: URI;
private readonly cache: number;
private readonly cleanUpPromise: Promise<void>;
constructor(
@IEnvironmentService environmentService: INativeEnvironmentService,
@@ -31,11 +30,9 @@ export class ExtensionsDownloader extends Disposable {
@ILogService private readonly logService: ILogService,
) {
super();
if (environmentService.extensionsDownloadPath) {
this.extensionsDownloadDir = URI.file(environmentService.extensionsDownloadPath);
this.cache = 20; // Cache 20 downloads
this.cleanUpPromise = this.cleanUp();
}
this.extensionsDownloadDir = URI.file(environmentService.extensionsDownloadPath);
this.cache = 20; // Cache 20 downloads
this.cleanUpPromise = this.cleanUp();
}
async downloadExtension(extension: IGalleryExtension, operation: InstallOperation): Promise<URI> {
@@ -46,10 +43,7 @@ export class ExtensionsDownloader extends Disposable {
}
async delete(location: URI): Promise<void> {
// Delete immediately if caching is disabled
if (!this.cache) {
await this.fileService.del(location);
}
// noop as caching is enabled always
}
private async download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<void> {

View File

@@ -61,7 +61,7 @@ interface InstallableExtension {
export class ExtensionManagementService extends Disposable implements IExtensionManagementService {
_serviceBrand: undefined;
declare readonly _serviceBrand: undefined;
private readonly extensionsScanner: ExtensionsScanner;
private reportedExtensions: Promise<IReportedExtension[]> | undefined;
@@ -178,7 +178,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
if (identifierWithVersion.equals(new ExtensionIdentifierWithVersion(existing.identifier, existing.manifest.version))) {
return this.extensionsScanner.removeExtension(existing, 'existing').then(null, e => Promise.reject(new Error(nls.localize('restartCode', "Please restart Azure Data Studio before reinstalling {0}.", manifest.displayName || manifest.name))));
} else if (semver.gt(existing.manifest.version, manifest.version)) {
return this.uninstall(existing, true);
return this.uninstallExtension(existing);
}
} else {
// Remove the extension with same version if it is already uninstalled.
@@ -309,7 +309,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
.then(local => this.extensionsDownloader.delete(URI.file(installableExtension.zipPath)).finally(() => { }).then(() => local));
})
.then(local => this.installDependenciesAndPackExtensions(local, existingExtension)
.then(() => local, error => this.uninstall(local, true).then(() => Promise.reject(error), () => Promise.reject(error))))
.then(() => local, error => this.uninstall(local).then(() => Promise.reject(error), () => Promise.reject(error))))
.then(
async local => {
if (existingExtension && semver.neq(existingExtension.manifest.version, extension.version)) {
@@ -480,11 +480,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
return this.getInstalled(ExtensionType.User)
.then(installed =>
Promise.all(installed.filter(local => extensions.some(galleryExtension => new ExtensionIdentifierWithVersion(local.identifier, local.manifest.version).equals(new ExtensionIdentifierWithVersion(galleryExtension.identifier, galleryExtension.version)))) // Check with version because we want to rollback the exact version
.map(local => this.uninstall(local, true))))
.map(local => this.uninstall(local))))
.then(() => undefined, () => undefined);
}
uninstall(extension: ILocalExtension, force = false): Promise<void> {
uninstall(extension: ILocalExtension): Promise<void> {
this.logService.trace('ExtensionManagementService#uninstall', extension.identifier.id);
return this.toNonCancellablePromise(this.getInstalled(ExtensionType.User)
.then(installed => {