Browse Source

[desktop] Upgrade to Electron 30.0.5 to fix Linux crash when maximizing window (#1731)

Manav Rathi 1 year ago
parent
commit
aa6b904b0b

+ 19 - 10
desktop/src/main/log.ts

@@ -38,28 +38,32 @@ export const logToDisk = (message: string) => {
     log.info(`[rndr] ${message}`);
 };
 
-const logError = (message: string, e?: unknown) => {
-    if (!e) {
-        logError_(message);
-        return;
-    }
+const messageWithError = (message: string, e?: unknown) => {
+    if (!e) return message;
 
     let es: string;
     if (e instanceof Error) {
         // In practice, we expect ourselves to be called with Error objects, so
         // this is the happy path so to say.
-        es = `${e.name}: ${e.message}\n${e.stack}`;
+        es = [`${e.name}: ${e.message}`, e.stack].filter((x) => x).join("\n");
     } else {
         // For the rest rare cases, use the default string serialization of e.
         es = String(e);
     }
 
-    logError_(`${message}: ${es}`);
+    return `${message}: ${es}`;
 };
 
-const logError_ = (message: string) => {
-    log.error(`[main] [error] ${message}`);
-    console.error(`[error] ${message}`);
+const logError = (message: string, e?: unknown) => {
+    const m = `[error] ${messageWithError(message, e)}`;
+    console.error(m);
+    log.error(`[main] ${m}`);
+};
+
+const logWarn = (message: string, e?: unknown) => {
+    const m = `[warn] ${messageWithError(message, e)}`;
+    console.error(m);
+    log.error(`[main] ${m}`);
 };
 
 const logInfo = (...params: unknown[]) => {
@@ -97,6 +101,11 @@ export default {
      * console.
      */
     error: logError,
+    /**
+     * Sibling of {@link error}, with the same parameters and behaviour, except
+     * it gets prefixed with a warning instead of an error tag.
+     */
+    warn: logWarn,
     /**
      * Log a message.
      *

+ 4 - 3
desktop/src/main/services/app-update.ts

@@ -137,12 +137,10 @@ const checkForUpdatesAndNotify = async (mainWindow: BrowserWindow) => {
     const showUpdateDialog = (update: AppUpdate) =>
         mainWindow.webContents.send("appUpdateAvailable", update);
 
-    log.debug(() => "Attempting auto update");
-    await autoUpdater.downloadUpdate();
-
     let timeout: ReturnType<typeof setTimeout>;
     const fiveMinutes = 5 * 60 * 1000;
     autoUpdater.on("update-downloaded", () => {
+        log.info(`Update downloaded ${version}`);
         timeout = setTimeout(
             () => showUpdateDialog({ autoUpdatable: true, version }),
             fiveMinutes,
@@ -154,6 +152,9 @@ const checkForUpdatesAndNotify = async (mainWindow: BrowserWindow) => {
         log.error("Auto update failed", error);
         showUpdateDialog({ autoUpdatable: false, version });
     });
+
+    log.info(`Downloading update ${version}`);
+    await autoUpdater.downloadUpdate();
 };
 
 /**

+ 9 - 3
desktop/src/main/services/upload.ts

@@ -3,6 +3,7 @@ import fs from "node:fs/promises";
 import path from "node:path";
 import { existsSync } from "original-fs";
 import type { PendingUploads, ZipItem } from "../../types/ipc";
+import log from "../log";
 import { uploadStatusStore } from "../stores/upload-status";
 
 export const listZipItems = async (zipPath: string): Promise<ZipItem[]> => {
@@ -64,11 +65,16 @@ export const pendingUploads = async (): Promise<PendingUploads | undefined> => {
     // file, but the dedup logic will kick in at that point so no harm will come
     // of it.
     if (allZipItems === undefined) {
-        const allZipPaths = uploadStatusStore.get("filePaths") ?? [];
+        const allZipPaths = uploadStatusStore.get("zipPaths") ?? [];
         const zipPaths = allZipPaths.filter((f) => existsSync(f));
         zipItems = [];
-        for (const zip of zipPaths)
-            zipItems = zipItems.concat(await listZipItems(zip));
+        for (const zip of zipPaths) {
+            try {
+                zipItems = zipItems.concat(await listZipItems(zip));
+            } catch (e) {
+                log.error("Ignoring items in malformed zip", e);
+            }
+        }
     } else {
         zipItems = allZipItems.filter(([z]) => existsSync(z));
     }

+ 6 - 6
desktop/yarn.lock

@@ -316,9 +316,9 @@
   integrity sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==
 
 "@types/node@*", "@types/node@^20.9.0":
-  version "20.12.11"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.11.tgz#c4ef00d3507000d17690643278a60dc55a9dc9be"
-  integrity sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==
+  version "20.12.12"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.12.tgz#7cbecdf902085cec634fdb362172dfe12b8f2050"
+  integrity sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==
   dependencies:
     undici-types "~5.26.4"
 
@@ -1266,9 +1266,9 @@ electron-updater@^6.1:
     tiny-typed-emitter "^2.1.0"
 
 electron@^30:
-  version "30.0.3"
-  resolved "https://registry.yarnpkg.com/electron/-/electron-30.0.3.tgz#7c25ddb12ba89fd117991d010f1b274b1bafcb73"
-  integrity sha512-h+suwx6e0fnv/9wi0/cmCMtG+4LrPzJZa+3DEEpxcPcP+pcWnBI70t8QspxgMNIh2wzXLMD9XVqrLkEbiBAInw==
+  version "30.0.5"
+  resolved "https://registry.yarnpkg.com/electron/-/electron-30.0.5.tgz#cbd28681b974f9d8ada987bf7070cde232d01a91"
+  integrity sha512-+a7PjcAq2HrfF1l+Ez8n0W9YeZIam7E9ERHEGs+L2dqKu7qxk8GNSEFoBEPCpLI00p/fc0d76L9IcLCQJdNFqA==
   dependencies:
     "@electron/get" "^2.0.0"
     "@types/node" "^20.9.0"

+ 1 - 3
web/apps/photos/src/components/Sidebar/Preferences/LanguageSelector.tsx

@@ -9,9 +9,7 @@ import { t } from "i18next";
 import { useRouter } from "next/router";
 
 /**
- * Human readable name for each supported locale
- *
- * TODO (MR): This names themselves should be localized.
+ * Human readable name for each supported locale.
  */
 export const localeName = (locale: SupportedLocale) => {
     switch (locale) {

+ 0 - 5
web/apps/photos/src/services/upload/uploadService.ts

@@ -1023,11 +1023,6 @@ const withThumbnail = async (
         } catch (e) {
             if (e.message.endsWith(CustomErrorMessage.NotAvailable)) {
                 moduleState.isNativeImageThumbnailGenerationNotAvailable = true;
-                // TODO(MR): release 1.7
-                log.info(
-                    "Setting isNativeImageThumbnailGenerationNotAvailable",
-                    e,
-                );
             } else {
                 log.error("Native thumbnail generation failed", e);
             }

+ 0 - 2
web/apps/photos/src/utils/file/index.ts

@@ -309,8 +309,6 @@ export const getRenderableImage = async (fileName: string, imageBlob: Blob) => {
             } catch (e) {
                 if (e.message.endsWith(CustomErrorMessage.NotAvailable)) {
                     moduleState.isNativeJPEGConversionNotAvailable = true;
-                    // TODO(MR): release 1.7
-                    log.info("Setting isNativeJPEGConversionNotAvailable", e);
                 } else {
                     log.error("Native conversion to JPEG failed", e);
                 }

+ 22 - 13
web/docs/dependencies.md

@@ -5,28 +5,37 @@
 These are some global dev dependencies in the root `package.json`. These set the
 baseline for how our code be in all the workspaces in this (yarn) monorepo.
 
--   "prettier" - Formatter
--   "eslint" - Linter
--   "typescript" - Type checker
+-   [prettier](https://prettier.io) - Formatter
+
+-   [eslint](https://eslint.org) - Linter
+
+-   [typescript](https://www.typescriptlang.org/) - Type checker
 
 They also need some support packages, which come from the leaf `@/build-config`
 package:
 
--   "@typescript-eslint/parser" - Tells ESLint how to read TypeScript syntax.
+-   [@typescript-eslint/parser](https://typescript-eslint.io/packages/eslint-plugin/)
+    \- Tells ESLint how to read TypeScript syntax.
+
+-   [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/packages/eslint-plugin/)
+    \- Provides TypeScript rules and presets
 
--   "@typescript-eslint/eslint-plugin" - Provides TypeScript rules and presets
+-   [eslint-plugin-react-hooks](https://github.com/jsx-eslint/eslint-plugin-react),
+    [eslint-plugin-react-hooks](https://reactjs.org/) \- Some React specific
+    ESLint rules and configurations that are used by the workspaces that have
+    React code.
 
--   "eslint-plugin-react-hooks", "eslint-plugin-react-namespace-import" - Some
-    React specific ESLint rules and configurations that are used by the
-    workspaces that have React code.
+-   [eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
+    \- A plugin to ensure that React components are exported in a way that they
+    can be HMR-ed.
 
--   "eslint-plugin-react-refresh" - A plugin to ensure that React components are
-    exported in a way that they can be HMR-ed.
+-   [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports)
+    \- A Prettier plugin to sort imports.
 
--   "prettier-plugin-organize-imports" - A Prettier plugin to sort imports.
+-   [prettier-plugin-packagejson](https://github.com/matzkoh/prettier-plugin-packagejson)
+    \- A Prettier plugin to also prettify `package.json`.
 
--   "prettier-plugin-packagejson" - A Prettier plugin to also prettify
-    `package.json`.
+The root `package.json` also has a convenience dev dependency:
 
 -   [concurrently](https://github.com/open-cli-tools/concurrently) for spawning
     parallel tasks when we invoke various yarn scripts.

+ 2 - 2
web/packages/build-config/package.json

@@ -7,8 +7,8 @@
         "@typescript-eslint/parser": "^7",
         "eslint-plugin-react": "^7.34",
         "eslint-plugin-react-hooks": "^4.6",
-        "eslint-plugin-react-refresh": "^0.4.6",
+        "eslint-plugin-react-refresh": "^0.4.7",
         "prettier-plugin-organize-imports": "^3.2",
-        "prettier-plugin-packagejson": "^2.4"
+        "prettier-plugin-packagejson": "^2.5"
     }
 }

+ 20 - 14
web/yarn.lock

@@ -2319,15 +2319,20 @@ eslint-plugin-jsx-a11y@^6.7.1:
     object.entries "^1.1.7"
     object.fromentries "^2.0.7"
 
-"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705", eslint-plugin-react-hooks@^4.6:
+"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705":
   version "4.6.0"
   resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
   integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==
 
-eslint-plugin-react-refresh@^0.4.6:
-  version "0.4.6"
-  resolved "https://registry.yarnpkg.com/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.6.tgz#e8e8accab681861baed00c5c12da70267db0936f"
-  integrity sha512-NjGXdm7zgcKRkKMua34qVO9doI7VOxZ6ancSvBELJSSoX97jyndXcSoa8XBh69JoB31dNz3EEzlMcizZl7LaMA==
+eslint-plugin-react-hooks@^4.6:
+  version "4.6.2"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz#c829eb06c0e6f484b3fbb85a97e57784f328c596"
+  integrity sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==
+
+eslint-plugin-react-refresh@^0.4.7:
+  version "0.4.7"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.7.tgz#1f597f9093b254f10ee0961c139a749acb19af7d"
+  integrity sha512-yrj+KInFmwuQS2UQcg1SF83ha1tuHC1jMQbRNyuWtlEzzKRDgAl7L4Yp4NlDUZTZNlWvHEzOtJhMi40R7JxcSw==
 
 eslint-plugin-react@^7.33.2:
   version "7.33.2"
@@ -3855,12 +3860,12 @@ prettier-plugin-organize-imports@^3.2:
   resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.4.tgz#77967f69d335e9c8e6e5d224074609309c62845e"
   integrity sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog==
 
-prettier-plugin-packagejson@^2.4:
-  version "2.4.12"
-  resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.4.12.tgz#eeb917dad83ae42d0caccc9f26d3728b5c4f2434"
-  integrity sha512-hifuuOgw5rHHTdouw9VrhT8+Nd7UwxtL1qco8dUfd4XUFQL6ia3xyjSxhPQTsGnSYFraTWy5Omb+MZm/OWDTpQ==
+prettier-plugin-packagejson@^2.5:
+  version "2.5.0"
+  resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.5.0.tgz#23d2cb8b1f7840702d35e3a5078e564ea0bc63e0"
+  integrity sha512-6XkH3rpin5QEQodBSVNg+rBo4r91g/1mCaRwS1YGdQJZ6jwqrg2UchBsIG9tpS1yK1kNBvOt84OILsX8uHzBGg==
   dependencies:
-    sort-package-json "2.8.0"
+    sort-package-json "2.10.0"
     synckit "0.9.0"
 
 prettier@^3:
@@ -4336,10 +4341,10 @@ sort-object-keys@^1.1.3:
   resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45"
   integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==
 
-sort-package-json@2.8.0:
-  version "2.8.0"
-  resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.8.0.tgz#6a46439ad0fef77f091e678e103f03ecbea575c8"
-  integrity sha512-PxeNg93bTJWmDGnu0HADDucoxfFiKkIr73Kv85EBThlI1YQPdc0XovBgg2llD0iABZbu2SlKo8ntGmOP9wOj/g==
+sort-package-json@2.10.0:
+  version "2.10.0"
+  resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.10.0.tgz#6be07424bf3b7db9fbb1bdd69e7945f301026d8a"
+  integrity sha512-MYecfvObMwJjjJskhxYfuOADkXp1ZMMnCFC8yhp+9HDsk7HhR336hd7eiBs96lTXfiqmUNI+WQCeCMRBhl251g==
   dependencies:
     detect-indent "^7.0.1"
     detect-newline "^4.0.0"
@@ -4347,6 +4352,7 @@ sort-package-json@2.8.0:
     git-hooks-list "^3.0.0"
     globby "^13.1.2"
     is-plain-obj "^4.1.0"
+    semver "^7.6.0"
     sort-object-keys "^1.1.3"
 
 source-map-js@^1.0.2: