Skip to content

Commit

Permalink
#782 disable auto upgrade workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
janproch committed May 17, 2024
1 parent 8ba85ac commit c82a877
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const path = require('path');
const url = require('url');
const mainMenuDefinition = require('./mainMenuDefinition');
const { settings } = require('cluster');
let disableAutoUpgrade = false;

// require('@electron/remote/main').initialize();

Expand Down Expand Up @@ -49,11 +50,21 @@ const isMac = () => os.platform() == 'darwin';

try {
initialConfig = JSON.parse(fs.readFileSync(configRootPath, { encoding: 'utf-8' }));
disableAutoUpgrade = initialConfig['disableAutoUpgrade'] || false;
} catch (err) {
console.log('Error loading config-root:', err.message);
initialConfig = {};
}

if (process.argv.includes('--disable-auto-upgrade')) {
console.log('Disabling auto-upgrade');
disableAutoUpgrade = true;
}
if (process.argv.includes('--enable-auto-upgrade')) {
console.log('Enabling auto-upgrade');
disableAutoUpgrade = false;
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
Expand Down Expand Up @@ -321,6 +332,7 @@ function createWindow() {
JSON.stringify({
winBounds: mainWindow.getBounds(),
winIsMaximized: mainWindow.isMaximized(),
disableAutoUpgrade,
}),
'utf-8'
);
Expand Down Expand Up @@ -383,7 +395,10 @@ function createWindow() {
}

function onAppReady() {
if (!process.env.DEVMODE) {
if (disableAutoUpgrade) {
console.log('Auto-upgrade is disabled, run dbgate --enable-auto-upgrade to enable');
}
if (!process.env.DEVMODE && !disableAutoUpgrade) {
autoUpdater.checkForUpdatesAndNotify();
}
createWindow();
Expand Down

0 comments on commit c82a877

Please sign in to comment.