π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[desktop] Graceful shutdown in dev mode
Manav Rathi86f79575aa51
diff --git a/desktop/src/main.ts b/desktop/src/main.tsindex 2622d09a6e..20d91ffd9a 100644--- a/desktop/src/main.ts+++ b/desktop/src/main.ts@@ -109,6 +109,8 @@ const main = () => {//// Note that some Electron APIs can only be used after this event occurs.void app.whenReady().then(() => {+ attachProcessHandlers();+void (async () => {// Create window and prepare for the renderer.mainWindow = createMainWindow();@@ -260,6 +262,23 @@ const handleEnteLinks = (mainWindow: BrowserWindow, url: string) => {mainWindow.webContents.send("openURL", url);};+/** Attach handlers to the (node) process. */+const attachProcessHandlers = () => {+ // Gracefully quit the app if we get a SIGINT.+ //+ // This is meant to allow graceful shutdowns during development, when the+ // app is launched using `yarn dev`. In such cases, pressing CTRL-C sends a+ // SIGINT to the process. The default handling of SIGINT is not graceful+ // enough (apparently), since I can observe that sometimes recent writes to+ // local storage are lost. This has also been reported by other people:+ // https://github.com/electron/electron/issues/22048+ //+ // Hopefully handling SIGINT prevents that issue. But beyond that, it allows+ // us to also write out `userPreferences.json` (as would happen during a+ // normal quit sequence), so this is an improvement either ways.+ process.on("SIGINT", () => app.quit());+};+/*** Create an return the {@link BrowserWindow} that will form our app's UI.*