1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make downloading of update and what follows more deliberate as orphan promise

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
Iku-turso 2022-06-01 18:14:40 +03:00 committed by Janne Savolainen
parent 2cd18c7245
commit f23ee9c3ce
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -13,6 +13,7 @@ import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and
import downloadUpdateInjectable from "../download-update/download-update.injectable";
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise";
const processCheckingForUpdatesInjectable = getInjectable({
id: "process-checking-for-updates",
@ -26,6 +27,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
return async () => {
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
@ -66,8 +68,9 @@ const processCheckingForUpdatesInjectable = getInjectable({
checkingForUpdatesState.set(false);
});
// Note: intentional orphan promise to make download happen in the background
downloadUpdate().then(async ({ downloadWasSuccessful }) => {
withOrphanPromise(async () => {
const { downloadWasSuccessful } = await downloadUpdate();
if (!downloadWasSuccessful) {
broadcastChangeInUpdatingStatus({
eventId: "download-for-update-failed",
@ -86,7 +89,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
if (userWantsToInstallUpdate) {
quitAndInstallUpdate();
}
});
})();
};
},
});