Skip to content
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

[NEW] Disable autoupdate on windows installer #907

Merged
merged 4 commits into from
Oct 5, 2018
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
20 changes: 20 additions & 0 deletions build/installer.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
${Else}
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\66bed7da-e601-54e6-b2e8-7be611d82556"
${EndIf}
!insertMacro disableAutoUpdates
Delete "$SMSTARTUP\Rocket.Chat+.lnk"
!macroend

Expand All @@ -35,3 +36,22 @@
Delete "$SMSTARTUP\Rocket.Chat.lnk"
${EndIf}
!macroend

!macro disableAutoUpdates
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 "/disableAutoUpdates" $R1
${IfNot} ${Errors}
!insertMacro writeUpdateFile
${EndIf}
!macroend

!macro writeUpdateFile
FileOpen $4 "$APPDATA\Rocket.Chat\update.json" w
FileWrite $4 "{$\r$\n"
FileWrite $4 ' "canUpdate": false,$\r$\n'
FileWrite $4 ' "autoUpdate": false$\r$\n'
FileWrite $4 "}"
FileWrite $4 "$\r$\n"
FileClose $4
!macroend
13 changes: 8 additions & 5 deletions src/background/autoUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const loadUpdateSettings = (dir) => {
const appUpdateSettings = loadUpdateSettings(appDir);
const userUpdateSettings = loadUpdateSettings(userDataDir);
const updateSettings = (() => {
const defaultUpdateSettings = { autoUpdate: true };
const defaultUpdateSettings = { autoUpdate: true, canUpdate: true };

if (appUpdateSettings.forced) {
return Object.assign({}, defaultUpdateSettings, appUpdateSettings);
Expand Down Expand Up @@ -127,10 +127,13 @@ function updateAvailable({ version }) {
});
}

export const canUpdate = () =>
(process.platform === 'linux' && Boolean(process.env.APPIMAGE)) ||
(process.platform === 'win32' && !process.windowsStore) ||
(process.platform === 'darwin' && !process.mas);
export const canUpdate = () => {
return (updateSettings.canUpdate) && (
(process.platform === 'linux' && Boolean(process.env.APPIMAGE)) ||
(process.platform === 'win32' && !process.windowsStore) ||
(process.platform === 'darwin' && !process.mas)
);
};

export const canAutoUpdate = () => updateSettings.autoUpdate !== false;

Expand Down