Skip to content

Commit 5f22b4e

Browse files
authored
Fixed following issues related to auto-update:
1. Fixed the issue where auto-update was not working for macOS x64 arch machines as pgadmin4 zip file name has x86_64 in it. 2. Improved error handling in the /upgrade_check API by replacing the static “Failed to check for update” message for Windows users with a dynamic error message. 3. Fixed the CSS issue affecting the close icon in the warning notifier. 4. Removed trailing periods from helper texts and notifier messages in the app’s auto-update workflow. #9133
1 parent 758bbc7 commit 5f22b4e

File tree

9 files changed

+32
-29
lines changed

9 files changed

+32
-29
lines changed

pkg/mac/build-functions.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# shellcheck shell=bash
22

3+
# uname -m returns "x86_64" on Intel, but we need "x64"
4+
ARCH="x64"
5+
if [ "$(uname -m)" == "arm64" ]; then
6+
ARCH="arm64"
7+
fi
8+
39
_setup_env() {
410
FUNCS_DIR=$(cd "$(dirname "$0")" && pwd)/../..
511
APP_RELEASE=$(grep "^APP_RELEASE" "${FUNCS_DIR}/web/version.py" | cut -d"=" -f2 | sed 's/ //g')
@@ -11,7 +17,7 @@ _setup_env() {
1117
APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
1218
fi
1319
BUNDLE_DIR="${BUILD_ROOT}/${APP_NAME}.app"
14-
DMG_NAME="${DIST_ROOT}"/$(echo "${APP_NAME}" | sed 's/ //g' | awk '{print tolower($0)}')-"${APP_LONG_VERSION}-$(uname -m).dmg"
20+
DMG_NAME="${DIST_ROOT}/$(echo "${APP_NAME}" | sed 's/ //g' | awk '{print tolower($0)}')-${APP_LONG_VERSION}-${ARCH}.dmg"
1521
PYTHON_OS_VERSION="11"
1622
}
1723

@@ -27,20 +33,14 @@ _build_runtime() {
2733

2834
test -d "${BUILD_ROOT}" || mkdir "${BUILD_ROOT}"
2935
# Get a fresh copy of electron
30-
# uname -m returns "x86_64" on Intel, but we need "x64"
31-
ELECTRON_ARCH="x64"
32-
if [ "$(uname -m)" == "arm64" ]; then
33-
ELECTRON_ARCH="arm64"
34-
fi
35-
3636
ELECTRON_VERSION="$(npm info electron version)"
3737

3838
pushd "${BUILD_ROOT}" > /dev/null || exit
3939
while true;do
40-
wget "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/electron-v${ELECTRON_VERSION}-darwin-${ELECTRON_ARCH}.zip" && break
41-
rm "electron-v${ELECTRON_VERSION}-darwin-${ELECTRON_ARCH}.zip"
40+
wget "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/electron-v${ELECTRON_VERSION}-darwin-${ARCH}.zip" && break
41+
rm "electron-v${ELECTRON_VERSION}-darwin-${ARCH}.zip"
4242
done
43-
unzip "electron-v${ELECTRON_VERSION}-darwin-${ELECTRON_ARCH}.zip"
43+
unzip "electron-v${ELECTRON_VERSION}-darwin-${ARCH}.zip"
4444
popd > /dev/null || exit
4545
# WGET END
4646

runtime/src/js/autoUpdaterHandler.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ export function updateConfigAndMenus(event, configStore, pgAdminMainScreen, menu
2121
// This function registers autoUpdater event listeners ONCE
2222
function registerAutoUpdaterEvents({ pgAdminMainScreen, configStore, menuCallbacks }) {
2323
autoUpdater.on('checking-for-update', () => {
24-
misc.writeServerLog('[Auto-Updater]: Checking for update...');
24+
misc.writeServerLog('[Auto-Updater]: Checking for update.');
2525
});
2626

2727
autoUpdater.on('update-available', () => {
2828
updateConfigAndMenus('update-available', configStore, pgAdminMainScreen, menuCallbacks);
29-
misc.writeServerLog('[Auto-Updater]: Update downloading...');
29+
misc.writeServerLog('[Auto-Updater]: Update downloading.');
3030
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', { update_downloading: true });
3131
});
3232

3333
autoUpdater.on('update-not-available', () => {
3434
updateConfigAndMenus('update-not-available', configStore, pgAdminMainScreen, menuCallbacks);
35-
misc.writeServerLog('[Auto-Updater]: No update available...');
35+
misc.writeServerLog('[Auto-Updater]: No update available.');
3636
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', { no_update_available: true });
3737
});
3838

3939
autoUpdater.on('update-downloaded', () => {
4040
updateConfigAndMenus('update-downloaded', configStore, pgAdminMainScreen, menuCallbacks);
41-
misc.writeServerLog('[Auto-Updater]: Update downloaded...');
41+
misc.writeServerLog('[Auto-Updater]: Update downloaded.');
4242
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', { update_downloaded: true });
4343
});
4444

@@ -82,7 +82,7 @@ function handleSendDataForAppUpdate({
8282

8383
try {
8484
autoUpdater.setFeedURL({ url: serverUrl });
85-
misc.writeServerLog('[Auto-Updater]: Initiating update check...');
85+
misc.writeServerLog('[Auto-Updater]: Initiating update check.');
8686
autoUpdater.checkForUpdates();
8787
} catch (err) {
8888
misc.writeServerLog('[Auto-Updater]: Error setting autoUpdater feed URL: ' + err.message);

runtime/src/js/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function handleAutoUpdateMenu(menuFile, configStore, callbacks) {
7575
menuFile.submenu.unshift({
7676
name: 'mnu_restart_to_update',
7777
id: 'mnu_restart_to_update',
78-
label: 'Restart to Update...',
78+
label: 'Restart to Update',
7979
enabled: true,
8080
priority: 998,
8181
click: callbacks['restart_to_update'],

runtime/src/js/pgadmin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,14 @@ function notifyUpdateInstalled() {
443443
try {
444444
// Notify renderer
445445
if (pgAdminMainScreen) {
446-
misc.writeServerLog('[Auto-Updater]: Update installed successfully...');
446+
misc.writeServerLog('[Auto-Updater]: Update installed successfully.');
447447
setTimeout(() => {
448448
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {update_installed: true});
449449
}, 10000);
450450
} else {
451451
// If main screen not ready, wait and send after it's created
452452
app.once('browser-window-created', (event, window) => {
453-
misc.writeServerLog('[Auto-Updater]: Update installed successfully...');
453+
misc.writeServerLog('[Auto-Updater]: Update installed successfully.');
454454
setTimeout(() => {
455455
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {update_installed: true});
456456
}, 10000);

web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,11 @@ def _get_sql_for_edit_mode(self, data, parallel_dict, all_ids_dict,
11711171
old_data['proparallel'] = \
11721172
parallel_dict[old_data['proparallel']]
11731173

1174-
if self.node_type == 'function' and \
1175-
old_data['dependsonextensions'] is None:
1176-
old_data['dependsonextensions'] = []
1174+
if self.node_type == 'function':
1175+
old_data['dependsonextensions'] = \
1176+
old_data.get('dependsonextensions') or []
1177+
data['dependsonextensions'] = \
1178+
data.get('dependsonextensions') or []
11771179

11781180
# If any of the below argument is changed,
11791181
# then CREATE OR REPLACE SQL statement should be called

web/pgadmin/browser/static/js/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ define('pgadmin.browser', [
282282
});
283283
const isDesktopWithAutoUpdate = pgAdmin.server_mode == 'False' && data.check_for_auto_updates && data.auto_update_url !== '';
284284
const isUpdateAvailable = data.outdated && data.upgrade_version_int > data.current_version_int;
285-
const noUpdateMessage = 'No update available...';
285+
const noUpdateMessage = 'No update available.';
286286
// This is for desktop installers whose auto_update_url is mentioned in https://www.pgadmin.org/versions.json
287287
if (isDesktopWithAutoUpdate) {
288288
if (isUpdateAvailable) {

web/pgadmin/misc/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from urllib.request import urlopen
3535
from urllib.parse import unquote
3636
from pgadmin.settings import get_setting, store_setting
37+
import html
3738

3839
MODULE_NAME = 'misc'
3940

@@ -389,10 +390,11 @@ def upgrade_check():
389390
if response.getcode() == 200:
390391
data = json.loads(response.read().decode('utf-8'))
391392
current_app.logger.debug('Response data: %s' % data)
392-
except Exception:
393-
current_app.logger.exception(
394-
'Exception when checking for update')
395-
return internal_server_error('Failed to check for update')
393+
except Exception as e:
394+
current_app.logger.exception(e)
395+
# Escaping the error message to prevent HTML execution in UI
396+
escaped_error = html.escape(str(e))
397+
return internal_server_error(errormsg=escaped_error)
396398

397399
if data and config.UPGRADE_CHECK_KEY and \
398400
config.UPGRADE_CHECK_KEY in data:

web/pgadmin/static/js/BrowserComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ export default function BrowserComponent({pgAdmin}) {
198198
if (data?.check_version_update) {
199199
pgAdmin.Browser.check_version_update(true);
200200
} else if (data.update_downloading) {
201-
appAutoUpdateNotifier('Update downloading...', 'info', null, 10000);
201+
appAutoUpdateNotifier('Update downloading.', 'info', null, 10000);
202202
} else if (data.no_update_available) {
203-
appAutoUpdateNotifier('No update available...', 'info', null, 10000);
203+
appAutoUpdateNotifier('No update available.', 'info', null, 10000);
204204
} else if (data.update_downloaded) {
205205
const UPDATE_DOWNLOADED_MESSAGE = gettext('An update is ready. Restart the app now to install it, or later to keep using the current version.');
206206
appAutoUpdateNotifier(UPDATE_DOWNLOADED_MESSAGE, 'warning', installUpdate, null, 'Update downloaded', 'update_downloaded');

web/pgadmin/static/js/components/FormComponents.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ const StyledNotifierMessageBox = styled(Box)(({theme}) => ({
12871287
backgroundColor: theme.palette.warning.light,
12881288
'& .FormFooter-iconWarning': {
12891289
color: theme.palette.warning.main,
1290-
marginBottom: theme.spacing(8),
12911290
},
12921291
},
12931292
'& .FormFooter-message': {

0 commit comments

Comments
 (0)