src/vs/platform/extensionManagement/node/extensionDownloader.ts/ExtensionsDownloader/downloadExtension
class ExtensionsDownloader:	async downloadExtension(extension: IGalleryExtension, operation: InstallOperation): Promise<URI> {
		await this.cleanUpPromise;
		const vsixName = this.getName(extension);
		const location = joinPath(this.extensionsDownloadDir, vsixName);

		// Download only if vsix does not exist
		if (!await this.fileService.exists(location)) {
			// Download to temporary location first only if vsix does not exist
			const tempLocation = joinPath(this.extensionsDownloadDir, `.${generateUuid()}`);
			if (!await this.fileService.exists(tempLocation)) {
				await this.extensionGalleryService.download(extension, tempLocation, operation);
			}

			try {
				// Rename temp location to original
				await this.rename(tempLocation, location, Date.now() + (2 * 60 * 1000) /* Retry for 2 minutes */);
			} catch (error) {
				try {
					await this.fileService.del(tempLocation);
				} catch (e) { /* ignore */ }
				if (error.code === 'ENOTEMPTY') {
					this.logService.info(`Rename failed because vsix was downloaded by another source. So ignoring renaming.`, extension.identifier.id);
				} else {
					this.logService.info(`Rename failed because of ${getErrorMessage(error)}. Deleted the vsix from downloaded location`, tempLocation.path);
					throw error;
				}
			}

		}

		return location;
	}