You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Windows: Re-enable the beta "auto-update" feature flag (#11802)
This commit is contained in:
@@ -556,8 +556,11 @@ class Application extends BaseApplication {
|
||||
value: Setting.value('flagOpenDevTools'),
|
||||
});
|
||||
|
||||
// Always disable for now - and disable too for the few apps that may have the flag enabled.
|
||||
// Always disable on Mac for now - and disable too for the few apps that may have the flag enabled.
|
||||
// At present, it only seems to work on Windows.
|
||||
if (shim.isMac()) {
|
||||
Setting.setValue('featureFlag.autoUpdaterServiceEnabled', false);
|
||||
}
|
||||
|
||||
// Note: Auto-update is a misnomer in the code.
|
||||
// The code below only checks, if a new version is available.
|
||||
|
||||
@@ -53,6 +53,7 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {
|
||||
private includePreReleases_ = false;
|
||||
private allowDowngrade = false;
|
||||
private isManualCheckInProgress = false;
|
||||
private isUpdateInProgress = false;
|
||||
|
||||
public constructor(mainWindow: BrowserWindow, logger: LoggerWrapper, devMode: boolean, includePreReleases: boolean) {
|
||||
this.window_ = mainWindow;
|
||||
@@ -125,6 +126,12 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {
|
||||
};
|
||||
|
||||
private checkForLatestRelease = async (): Promise<void> => {
|
||||
if (this.isUpdateInProgress) {
|
||||
this.logger_.info('An update check is already in progress');
|
||||
return;
|
||||
}
|
||||
this.isUpdateInProgress = true;
|
||||
|
||||
try {
|
||||
const release: GitHubRelease = await this.fetchLatestRelease(this.includePreReleases_);
|
||||
|
||||
@@ -134,13 +141,16 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {
|
||||
assetUrl = assetUrl.substring(0, assetUrl.lastIndexOf('/'));
|
||||
autoUpdater.setFeedURL({ provider: 'generic', url: assetUrl });
|
||||
await autoUpdater.checkForUpdates();
|
||||
this.isManualCheckInProgress = false;
|
||||
} catch (error) {
|
||||
this.logger_.error(`Update download url failed: ${error.message}`);
|
||||
this.isUpdateInProgress = false;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
this.logger_.error(`Fetching releases failed: ${error.message}`);
|
||||
this.isUpdateInProgress = false;
|
||||
} finally {
|
||||
this.isManualCheckInProgress = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,6 +184,7 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {
|
||||
this.window_.webContents.send(AutoUpdaterEvents.UpdateNotAvailable);
|
||||
}
|
||||
|
||||
this.isUpdateInProgress = false;
|
||||
this.logger_.info('Update not available.');
|
||||
};
|
||||
|
||||
@@ -187,11 +198,13 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {
|
||||
|
||||
private onUpdateDownloaded = (info: UpdateInfo): void => {
|
||||
this.logger_.info('Update downloaded.');
|
||||
this.isUpdateInProgress = false;
|
||||
void this.promptUserToUpdate(info);
|
||||
};
|
||||
|
||||
private onError = (error: Error): void => {
|
||||
this.logger_.error('Error in auto-updater.', error);
|
||||
this.isUpdateInProgress = false;
|
||||
};
|
||||
|
||||
private promptUserToUpdate = async (info: UpdateInfo): Promise<void> => {
|
||||
|
||||
@@ -1672,12 +1672,12 @@ const builtInMetadata = (Setting: typeof SettingType) => {
|
||||
'featureFlag.autoUpdaterServiceEnabled': {
|
||||
value: false,
|
||||
type: SettingItemType.Bool,
|
||||
public: false,
|
||||
public: true,
|
||||
storage: SettingStorage.File,
|
||||
appTypes: [AppType.Desktop],
|
||||
label: () => 'Enable auto-updates',
|
||||
description: () => 'Enable this feature to receive notifications about updates and install them instead of manually downloading them. Restart app to start receiving auto-updates.',
|
||||
show: () => shim.isWindows() || shim.isMac(),
|
||||
show: () => shim.isWindows(),
|
||||
section: 'application',
|
||||
isGlobal: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user