mirror of
https://github.com/tutao/tutanota.git
synced 2025-10-19 07:53:47 +00:00
[desktop] Change DesktopUtils#relaunch to DesktopUtils#exit
We can't trust the path in the environment variable even if it's correct and factual, as we don't know if the file was modified. We also do not want to spend a lot of time writing code to verify it right now. To keep things simple, we're going to just close the app in these very exceptional cases.
This commit is contained in:
parent
247fc6f46a
commit
4261217094
4 changed files with 9 additions and 78 deletions
|
@ -89,7 +89,7 @@ export class DesktopErrorHandler {
|
|||
if (checkboxChecked) {
|
||||
log.debug("writing error log to", this._errorLogPath)
|
||||
fs.writeFileSync(this._errorLogPath, this.lastErrorLog ? JSON.stringify(this.lastErrorLog) : "")
|
||||
this.utils.relaunch()
|
||||
this.utils.exit()
|
||||
} else {
|
||||
const loggedInWindow = this.wm.getAll().find((w) => w.getUserId() != null)
|
||||
|
||||
|
|
|
@ -455,11 +455,7 @@ async function unlockDeviceKeychain(keyStoreFacade: DesktopKeyStoreFacade, wm: W
|
|||
type: "error",
|
||||
title: "Tuta Mail",
|
||||
message: lang.getTranslation("secretStorageError_msg", { "{url}": InfoLink.SecretStorage }).text,
|
||||
buttons: [
|
||||
lang.getTranslation("continue_action").text,
|
||||
lang.getTranslation("clearLocalData_action").text,
|
||||
lang.getTranslation("restart_action").text,
|
||||
],
|
||||
buttons: [lang.getTranslation("continue_action").text, lang.getTranslation("clearLocalData_action").text, lang.getTranslation("quit_action").text],
|
||||
defaultId: 2,
|
||||
cancelId: 0,
|
||||
})
|
||||
|
@ -467,7 +463,6 @@ async function unlockDeviceKeychain(keyStoreFacade: DesktopKeyStoreFacade, wm: W
|
|||
case 0:
|
||||
break
|
||||
case 1:
|
||||
utils.relaunch()
|
||||
for (const window of wm.getAll()) {
|
||||
log.debug("Closing window ", window.id)
|
||||
// ideally we would destroy the window but it leads to obscure segfaults
|
||||
|
@ -479,12 +474,11 @@ async function unlockDeviceKeychain(keyStoreFacade: DesktopKeyStoreFacade, wm: W
|
|||
log.debug("Invalidating keychain")
|
||||
await keyStoreFacade.invalidateKeychain()
|
||||
log.debug("Quitting app")
|
||||
app.quit()
|
||||
log.debug("App exited")
|
||||
utils.exit()
|
||||
break
|
||||
case 2:
|
||||
utils.relaunch()
|
||||
app.quit()
|
||||
utils.exit()
|
||||
break
|
||||
default:
|
||||
throw new ProgrammingError("Invalid choice")
|
||||
|
|
|
@ -255,36 +255,11 @@ export class DesktopUtils {
|
|||
}
|
||||
}
|
||||
|
||||
relaunch() {
|
||||
// we do not want to use
|
||||
const appImage = this.getAppImagePath()
|
||||
|
||||
if (appImage) {
|
||||
// TODO: We should verify the AppImage.
|
||||
|
||||
// electon.app.relaunch doesn't work inside AppImage, so we instead manually execute the appimage
|
||||
this.executor.runDetached({
|
||||
executable: appImage,
|
||||
|
||||
// argv[0] is the path to the executable, argv[1...] are the arguments
|
||||
args: this.process.argv.slice(1),
|
||||
})
|
||||
} else {
|
||||
this.electron.app.relaunch()
|
||||
}
|
||||
|
||||
exit() {
|
||||
this.electron.app.quit()
|
||||
this.electron.app.exit(0)
|
||||
}
|
||||
|
||||
private getAppImagePath(): string | null {
|
||||
if (!this.isLinux() || !this.electron.app.isPackaged) {
|
||||
return null
|
||||
} else {
|
||||
return this.process.env.APPIMAGE ?? null
|
||||
}
|
||||
}
|
||||
|
||||
isWindows(): boolean {
|
||||
return this.process.platform === "win32"
|
||||
}
|
||||
|
|
|
@ -26,47 +26,9 @@ o.spec("DesktopUtils", function () {
|
|||
desktopUtils = new DesktopUtils(process as NodeJS.Process, tempFs, electron, executor)
|
||||
})
|
||||
|
||||
o.spec("relaunch", () => {
|
||||
o.test("non-appimage calls relaunch", () => {
|
||||
Object.assign(app, { isPackaged: false })
|
||||
env.APPIMAGE = undefined
|
||||
process.argv = ["this string does not matter", "some", "args", "here"]
|
||||
process.platform = "linux"
|
||||
|
||||
desktopUtils.relaunch()
|
||||
verify(executor.runDetached(matchers.anything()), { times: 0 })
|
||||
verify(app.relaunch())
|
||||
o.test("exit", () => {
|
||||
desktopUtils.exit()
|
||||
verify(app.exit(0))
|
||||
verify(app.quit())
|
||||
})
|
||||
o.test("appimage on linux runs the appimage", () => {
|
||||
Object.assign(app, { isPackaged: true })
|
||||
env.APPIMAGE = "some_appimage.appimage"
|
||||
process.argv = ["this string does not matter", "some", "args", "here"]
|
||||
process.platform = "linux"
|
||||
|
||||
desktopUtils.relaunch()
|
||||
verify(
|
||||
executor.runDetached({
|
||||
executable: "some_appimage.appimage",
|
||||
args: ["some", "args", "here"],
|
||||
}),
|
||||
)
|
||||
verify(app.relaunch(), { times: 0 })
|
||||
verify(app.exit(0))
|
||||
verify(app.quit())
|
||||
})
|
||||
o.test("appimage on non-linux restarts the program", () => {
|
||||
Object.assign(app, { isPackaged: true })
|
||||
env.APPIMAGE = "some_appimage.appimage"
|
||||
process.argv = ["this string does not matter", "some", "args", "here"]
|
||||
process.platform = "win32"
|
||||
|
||||
desktopUtils.relaunch()
|
||||
verify(executor.runDetached(matchers.anything()), { times: 0 })
|
||||
verify(app.relaunch())
|
||||
verify(app.exit(0))
|
||||
verify(app.quit())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue