Prevent .deb packages from being opened with archive manager. #7502

Merged
Ruk33 merged 11 commits from 7495-deb-update-fails-to-launch-on-ubuntu into master 2022-07-07 22:48:43 +02:00
8 changed files with 58 additions and 12 deletions
Showing only changes of commit f46d0084eb - Show all commits

View file

@ -417,9 +417,9 @@ process.on('uncaughtException', error => {
}); });
// Auto updater // Auto updater
// autoUpdater.on('download-progress', (p) => { autoUpdater.on('download-progress', () => {
// rendererWindow.webContents.send('download-progress-update', p); updateState = UPDATE_STATE_DOWNLOADING;
// }); });
autoUpdater.on('update-downloaded', () => { autoUpdater.on('update-downloaded', () => {
updateState = UPDATE_STATE_DOWNLOADED; updateState = UPDATE_STATE_DOWNLOADED;
@ -434,6 +434,9 @@ autoUpdater.on('update-downloaded', () => {
}); });
autoUpdater.on('update-available', () => { autoUpdater.on('update-available', () => {
if (updateState === UPDATE_STATE_DOWNLOADING) {
return;
}
updateState = UPDATE_STATE_UPDATES_FOUND; updateState = UPDATE_STATE_UPDATES_FOUND;
}); });
@ -442,6 +445,10 @@ autoUpdater.on('update-not-available', () => {
}); });
autoUpdater.on('error', () => { autoUpdater.on('error', () => {
if (updateState === UPDATE_STATE_DOWNLOADING) {
updateState = UPDATE_STATE_UPDATES_FOUND;
return;
}
updateState = UPDATE_STATE_INIT; updateState = UPDATE_STATE_INIT;
}); });
@ -507,6 +514,10 @@ ipcMain.on('autoUpdateAccepted', () => {
return; return;
} }
if (updateState !== UPDATE_STATE_UPDATES_FOUND) {
return;
}
// If the update hasn't been downloaded, // If the update hasn't been downloaded,
// start downloading it. After it's done, the // start downloading it. After it's done, the
// event 'update-downloaded' will be triggered, // event 'update-downloaded' will be triggered,

View file

@ -60,6 +60,7 @@ export const AUTO_UPDATE_DECLINED = 'AUTO_UPDATE_DECLINED';
export const AUTO_UPDATE_RESET = 'AUTO_UPDATE_RESET'; export const AUTO_UPDATE_RESET = 'AUTO_UPDATE_RESET';
export const AUTO_UPDATE_FAILED = 'AUTO_UPDATE_FAILED'; export const AUTO_UPDATE_FAILED = 'AUTO_UPDATE_FAILED';
export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED'; export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED';
export const AUTO_UPDATE_DOWNLOADING = 'AUTO_UPDATE_DOWNLOADING';
export const CLEAR_UPGRADE_TIMER = 'CLEAR_UPGRADE_TIMER'; export const CLEAR_UPGRADE_TIMER = 'CLEAR_UPGRADE_TIMER';
// Wallet // Wallet

View file

@ -22,6 +22,7 @@ import {
doUpdateDownloadProgress, doUpdateDownloadProgress,
doNotifyUpdateAvailable, doNotifyUpdateAvailable,
doShowUpgradeInstallationError, doShowUpgradeInstallationError,
doAutoUpdateDownloading,
doAutoUpdateReset, doAutoUpdateReset,
doAutoUpdateFail, doAutoUpdateFail,
} from 'redux/actions/app'; } from 'redux/actions/app';
@ -131,12 +132,15 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
handleError(); handleError();
}); });
autoUpdater.on('download-progress', () => {
app.store.dispatch(doAutoUpdateDownloading());
});
autoUpdater.on('checking-for-update', () => { autoUpdater.on('checking-for-update', () => {
app.store.dispatch(doAutoUpdateReset()); app.store.dispatch(doAutoUpdateReset());
}); });
autoUpdater.on('update-available', (e) => { autoUpdater.on('update-available', (e) => {
app.store.dispatch(doAutoUpdateReset());
app.store.dispatch(doNotifyUpdateAvailable(e)); app.store.dispatch(doNotifyUpdateAvailable(e));
}); });

View file

@ -1,10 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doAutoUpdateDeclined, doHideModal } from 'redux/actions/app'; import { doAutoUpdateDeclined, doHideModal } from 'redux/actions/app';
import { selectAutoUpdateFailed } from 'redux/selectors/app'; import { selectAutoUpdateFailed, selectAutoUpdateDownloading, selectIsUpgradeAvailable } from 'redux/selectors/app';
import ModalAutoUpdateDownloaded from './view'; import ModalAutoUpdateDownloaded from './view';
const select = (state, props) => ({ const select = (state, props) => ({
errorWhileUpdating: selectAutoUpdateFailed(state), errorWhileUpdating: selectAutoUpdateFailed(state),
isDownloading: selectAutoUpdateDownloading(state),
isUpdateAvailable: selectIsUpgradeAvailable(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -1,5 +1,5 @@
// @flow // @flow
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
// @if TARGET='app' // @if TARGET='app'
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
// @endif // @endif
@ -10,15 +10,16 @@ type Props = {
closeModal: (any) => any, closeModal: (any) => any,
declineAutoUpdate: () => any, declineAutoUpdate: () => any,
errorWhileUpdating: boolean, errorWhileUpdating: boolean,
isDownloading: boolean,
isUpdateAvailable: boolean,
}; };
const ModalAutoUpdateDownloaded = (props: Props) => { const ModalAutoUpdateDownloaded = (props: Props) => {
const { closeModal, declineAutoUpdate, errorWhileUpdating } = props; const { closeModal, declineAutoUpdate, errorWhileUpdating, isDownloading, isUpdateAvailable } = props;
const [disabled, setDisabled] = useState(false); const [waitingForAutoUpdateResponse, setWaitingForAutoUpdateResponse] = useState(false);
const isDownloading = disabled && !errorWhileUpdating;
const handleConfirm = () => { const handleConfirm = () => {
setDisabled(true); setWaitingForAutoUpdateResponse(true);
ipcRenderer.send('autoUpdateAccepted'); ipcRenderer.send('autoUpdateAccepted');
}; };
@ -27,6 +28,10 @@ const ModalAutoUpdateDownloaded = (props: Props) => {
closeModal(); closeModal();
}; };
useEffect(() => {
setWaitingForAutoUpdateResponse(false);
}, [errorWhileUpdating, isDownloading, isUpdateAvailable]);
return ( return (
<Modal <Modal
isOpen isOpen
@ -34,8 +39,8 @@ const ModalAutoUpdateDownloaded = (props: Props) => {
contentLabel={__('Upgrade Downloaded')} contentLabel={__('Upgrade Downloaded')}
title={__('LBRY leveled up')} title={__('LBRY leveled up')}
confirmButtonLabel={isDownloading ? __('Downloading...') : __('Upgrade Now')} confirmButtonLabel={isDownloading ? __('Downloading...') : __('Upgrade Now')}
abortButtonLabel={__('Not Now')} abortButtonLabel={isDownloading ? __('Keep browsing') : __('Not Now')}
confirmButtonDisabled={isDownloading} confirmButtonDisabled={!isUpdateAvailable || isDownloading || waitingForAutoUpdateResponse}
onConfirmed={handleConfirm} onConfirmed={handleConfirm}
onAborted={handleAbort} onAborted={handleAbort}
> >

View file

@ -220,6 +220,12 @@ export function doNotifyUpdateAvailable(e) {
}; };
} }
export function doAutoUpdateDownloading() {
return {
type: ACTIONS.AUTO_UPDATE_DOWNLOADING,
};
}
export function doAutoUpdateReset() { export function doAutoUpdateReset() {
return { return {
type: ACTIONS.AUTO_UPDATE_RESET, type: ACTIONS.AUTO_UPDATE_RESET,

View file

@ -26,6 +26,7 @@ export type AppState = {
hasSignature: boolean, hasSignature: boolean,
badgeNumber: number, badgeNumber: number,
volume: number, volume: number,
autoUpdateDownloading: boolean,
autoUpdateDeclined: boolean, autoUpdateDeclined: boolean,
autoUpdateFailed: boolean, autoUpdateFailed: boolean,
modalsAllowed: boolean, modalsAllowed: boolean,
@ -63,6 +64,7 @@ const defaultState: AppState = {
upgradeSkipped: sessionStorage.getItem('upgradeSkipped') === 'true', upgradeSkipped: sessionStorage.getItem('upgradeSkipped') === 'true',
// @endif // @endif
muted: false, muted: false,
autoUpdateDownloading: false,
autoUpdateDownloaded: false, autoUpdateDownloaded: false,
autoUpdateDeclined: false, autoUpdateDeclined: false,
autoUpdateFailed: false, autoUpdateFailed: false,
@ -144,9 +146,18 @@ reducers[ACTIONS.UPGRADE_CANCELLED] = (state) =>
modal: null, modal: null,
}); });
reducers[ACTIONS.AUTO_UPDATE_DOWNLOADING] = (state) =>
Object.assign({}, state, {
autoUpdateDownloading: true,
autoUpdateDownloaded: false,
autoUpdateFailed: false,
});
reducers[ACTIONS.AUTO_UPDATE_DOWNLOADED] = (state) => reducers[ACTIONS.AUTO_UPDATE_DOWNLOADED] = (state) =>
Object.assign({}, state, { Object.assign({}, state, {
autoUpdateDownloading: false,
autoUpdateDownloaded: true, autoUpdateDownloaded: true,
autoUpdateFailed: false,
}); });
reducers[ACTIONS.AUTO_UPDATE_DECLINED] = (state) => reducers[ACTIONS.AUTO_UPDATE_DECLINED] = (state) =>
@ -157,10 +168,14 @@ reducers[ACTIONS.AUTO_UPDATE_DECLINED] = (state) =>
reducers[ACTIONS.AUTO_UPDATE_RESET] = (state) => reducers[ACTIONS.AUTO_UPDATE_RESET] = (state) =>
Object.assign({}, state, { Object.assign({}, state, {
autoUpdateFailed: false, autoUpdateFailed: false,
autoUpdateDownloading: false,
autoUpdateDownloaded: false,
}); });
reducers[ACTIONS.AUTO_UPDATE_FAILED] = (state) => reducers[ACTIONS.AUTO_UPDATE_FAILED] = (state) =>
Object.assign({}, state, { Object.assign({}, state, {
autoUpdateDownloading: false,
autoUpdateDownloaded: false,
autoUpdateFailed: true, autoUpdateFailed: true,
}); });

View file

@ -62,6 +62,8 @@ export const selectAutoUpdateDeclined = createSelector(selectState, (state) => s
export const selectAutoUpdateFailed = createSelector(selectState, (state) => state.autoUpdateFailed); export const selectAutoUpdateFailed = createSelector(selectState, (state) => state.autoUpdateFailed);
export const selectAutoUpdateDownloading = createSelector(selectState, (state) => state.autoUpdateDownloading);
export const selectIsUpdateModalDisplayed = createSelector(selectState, (state) => { export const selectIsUpdateModalDisplayed = createSelector(selectState, (state) => {
return [MODALS.AUTO_UPDATE_DOWNLOADED, MODALS.UPGRADE, MODALS.DOWNLOADING].includes(state.modal); return [MODALS.AUTO_UPDATE_DOWNLOADED, MODALS.UPGRADE, MODALS.DOWNLOADING].includes(state.modal);
}); });