Skip to content

Automatically check for updates only once #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
config:
- os: windows-latest
- os: windows-2019
- os: ubuntu-18.04 # https://github.com/arduino/arduino-ide/issues/259
- os: macos-latest
runs-on: ${{ matrix.config.os }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ArduinoFrontendContribution
this.updaterService.init(
this.arduinoPreferences.get('arduino.ide.updateChannel')
);
this.updater.checkForUpdates().then(async (updateInfo) => {
this.updater.checkForUpdates(true).then(async (updateInfo) => {
if (!updateInfo) return;
const versionToSkip = await this.localStorageService.getData<string>(
SKIP_IDE_VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class IDEUpdaterCommands implements CommandContribution {
});
}

async checkForUpdates(): Promise<UpdateInfo | void> {
return await this.updater.checkForUpdates();
async checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void> {
return await this.updater.checkForUpdates(initialCheck);
}

async downloadUpdate(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion arduino-ide-extension/src/common/protocol/ide-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const IDEUpdaterPath = '/services/ide-updater';
export const IDEUpdater = Symbol('IDEUpdater');
export interface IDEUpdater extends JsonRpcServer<IDEUpdaterClient> {
init(channel: UpdateChannel): void;
checkForUpdates(): Promise<UpdateInfo | void>;
checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void>;
downloadUpdate(): Promise<void>;
quitAndInstall(): void;
stopDownload(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const IDE_DOWNLOAD_BASE_URL = 'https://downloads.arduino.cc/arduino-ide';

@injectable()
export class IDEUpdaterImpl implements IDEUpdater {
private isAlreadyChecked = false;
private updater = autoUpdater;
private cancellationToken?: CancellationToken;
protected theiaFEClient?: IDEUpdaterClient;
protected clients: Array<IDEUpdaterClient> = [];

init(channel: UpdateChannel) {
init(channel: UpdateChannel): void {
this.updater.autoDownload = false;
this.updater.channel = channel;
this.updater.setFeedURL({
Expand Down Expand Up @@ -52,9 +53,16 @@ export class IDEUpdaterImpl implements IDEUpdater {
if (client) this.clients.push(client);
}

async checkForUpdates(): Promise<UpdateInfo | void> {
const { updateInfo, cancellationToken } =
await this.updater.checkForUpdates();
async checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void> {
if (initialCheck) {
if (this.isAlreadyChecked) return Promise.resolve();
this.isAlreadyChecked = true;
}

const {
updateInfo,
cancellationToken,
} = await this.updater.checkForUpdates();

this.cancellationToken = cancellationToken;
if (this.updater.currentVersion.compare(updateInfo.version) === -1) {
Expand Down