From 4bfc99b9126a098ec78f1b389071f31a43b2431d Mon Sep 17 00:00:00 2001 From: Francesco Stasi Date: Wed, 23 Feb 2022 17:44:57 +0100 Subject: [PATCH] Disable autodownload of updates on startup --- .../arduino-electron-main-module.ts | 2 +- .../ide-updater/ide-updater-impl.ts | 43 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) rename arduino-ide-extension/src/{node => electron-main}/ide-updater/ide-updater-impl.ts (82%) diff --git a/arduino-ide-extension/src/electron-main/arduino-electron-main-module.ts b/arduino-ide-extension/src/electron-main/arduino-electron-main-module.ts index 537030925..cb203236a 100644 --- a/arduino-ide-extension/src/electron-main/arduino-electron-main-module.ts +++ b/arduino-ide-extension/src/electron-main/arduino-electron-main-module.ts @@ -18,7 +18,7 @@ import { IDEUpdaterClient, IDEUpdaterPath, } from '../common/protocol/ide-updater'; -import { IDEUpdaterImpl } from '../node/ide-updater/ide-updater-impl'; +import { IDEUpdaterImpl } from './ide-updater/ide-updater-impl'; export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(ElectronMainApplication).toSelf().inSingletonScope(); diff --git a/arduino-ide-extension/src/node/ide-updater/ide-updater-impl.ts b/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts similarity index 82% rename from arduino-ide-extension/src/node/ide-updater/ide-updater-impl.ts rename to arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts index e40dbd997..88e3bea1f 100644 --- a/arduino-ide-extension/src/node/ide-updater/ide-updater-impl.ts +++ b/arduino-ide-extension/src/electron-main/ide-updater/ide-updater-impl.ts @@ -18,6 +18,7 @@ export class IDEUpdaterImpl implements IDEUpdater { protected clients: Array = []; init(channel: UpdateChannel) { + this.updater.autoDownload = false; this.updater.channel = channel; this.updater.setFeedURL({ provider: 'generic', @@ -27,24 +28,24 @@ export class IDEUpdaterImpl implements IDEUpdater { channel, }); - this.updater.on('checking-for-update', (e) => - this.clients.forEach((c) => c.notifyCheckingForUpdate(e)) - ); - this.updater.on('update-available', (e) => - this.clients.forEach((c) => c.notifyUpdateAvailable(e)) - ); - this.updater.on('update-not-available', (e) => - this.clients.forEach((c) => c.notifyUpdateNotAvailable(e)) - ); - this.updater.on('download-progress', (e) => - this.clients.forEach((c) => c.notifyDownloadProgressChanged(e)) - ); - this.updater.on('update-downloaded', (e) => - this.clients.forEach((c) => c.notifyDownloadFinished(e)) - ); - this.updater.on('error', (e) => - this.clients.forEach((c) => c.notifyError(e)) - ); + this.updater.on('checking-for-update', (e) => { + this.clients.forEach((c) => c.notifyCheckingForUpdate(e)); + }); + this.updater.on('update-available', (e) => { + this.clients.forEach((c) => c.notifyUpdateAvailable(e)); + }); + this.updater.on('update-not-available', (e) => { + this.clients.forEach((c) => c.notifyUpdateNotAvailable(e)); + }); + this.updater.on('download-progress', (e) => { + this.clients.forEach((c) => c.notifyDownloadProgressChanged(e)); + }); + this.updater.on('update-downloaded', (e) => { + this.clients.forEach((c) => c.notifyDownloadFinished(e)); + }); + this.updater.on('error', (e) => { + this.clients.forEach((c) => c.notifyError(e)); + }); } setClient(client: IDEUpdaterClient | undefined): void { @@ -52,10 +53,8 @@ export class IDEUpdaterImpl implements IDEUpdater { } async checkForUpdates(): Promise { - const { - updateInfo, - cancellationToken, - } = await this.updater.checkForUpdates(); + const { updateInfo, cancellationToken } = + await this.updater.checkForUpdates(); this.cancellationToken = cancellationToken; if (this.updater.currentVersion.compare(updateInfo.version) === -1) {