Skip to content

Add preference to set a custom update url #865

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 1 commit into from
Feb 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export class ArduinoFrontendContribution
}

this.updaterService.init(
this.arduinoPreferences.get('arduino.ide.updateChannel')
this.arduinoPreferences.get('arduino.ide.updateChannel'),
this.arduinoPreferences.get('arduino.ide.updateBaseUrl')
);
this.updater.checkForUpdates(true).then(async (updateInfo) => {
if (!updateInfo) return;
Expand Down
9 changes: 9 additions & 0 deletions arduino-ide-extension/src/browser/arduino-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export const ArduinoConfigSchema: PreferenceSchema = {
"Release channel to get updated from. 'stable' is the stable release, 'nightly' is the latest development build."
),
},
'arduino.ide.updateBaseUrl': {
type: 'string',
default: 'https://downloads.arduino.cc/arduino-ide',
description: nls.localize(
'arduino/preferences/ide.updateBaseUrl',
`The base URL where to download updates from. Defaults to 'https://downloads.arduino.cc/arduino-ide'`
),
},
'arduino.board.certificates': {
type: 'string',
description: nls.localize(
Expand Down Expand Up @@ -178,6 +186,7 @@ export interface ArduinoConfiguration {
'arduino.window.autoScale': boolean;
'arduino.window.zoomLevel': number;
'arduino.ide.updateChannel': UpdateChannel;
'arduino.ide.updateBaseUrl': string;
'arduino.board.certificates': string;
'arduino.sketchbook.showAllFiles': boolean;
'arduino.cloud.enabled': boolean;
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 @@ -46,7 +46,7 @@ export interface ProgressInfo {
export const IDEUpdaterPath = '/services/ide-updater';
export const IDEUpdater = Symbol('IDEUpdater');
export interface IDEUpdater extends JsonRpcServer<IDEUpdaterClient> {
init(channel: UpdateChannel): void;
init(channel: UpdateChannel, baseUrl: string): void;
checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void>;
downloadUpdate(): Promise<void>;
quitAndInstall(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '../../common/protocol/ide-updater';

const CHANGELOG_BASE_URL = 'https://downloads.arduino.cc/arduino-ide/changelog';
const IDE_DOWNLOAD_BASE_URL = 'https://downloads.arduino.cc/arduino-ide';

@injectable()
export class IDEUpdaterImpl implements IDEUpdater {
Expand All @@ -18,14 +17,12 @@ export class IDEUpdaterImpl implements IDEUpdater {
protected theiaFEClient?: IDEUpdaterClient;
protected clients: Array<IDEUpdaterClient> = [];

init(channel: UpdateChannel): void {
init(channel: UpdateChannel, baseUrl: string): void {
this.updater.autoDownload = false;
this.updater.channel = channel;
this.updater.setFeedURL({
provider: 'generic',
url: `${IDE_DOWNLOAD_BASE_URL}/${
channel === UpdateChannel.Nightly ? 'nightly' : ''
}`,
url: `${baseUrl}/${channel === UpdateChannel.Nightly ? 'nightly' : ''}`,
channel,
});

Expand Down