Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[desktop] Fix View logs hanging on Linux

aswinpradeepc1a0d75844f8f
diff --git a/desktop/changes/view-logs-linux.md b/desktop/changes/view-logs-linux.md
new file mode 100644
index 0000000000..254625a87b
--- /dev/null
+++ b/desktop/changes/view-logs-linux.md
@@ -0,0 +1 @@
+- Fixed the "View logs" button hanging on Linux instead of dismissing once the file manager opened.
diff --git a/desktop/src/main/services/dir.ts b/desktop/src/main/services/dir.ts
index bf44a10c29..f1aa9753fd 100644
--- a/desktop/src/main/services/dir.ts
+++ b/desktop/src/main/services/dir.ts
@@ -1,5 +1,6 @@
import { shell } from "electron/common";
import { app, dialog } from "electron/main";
+import { existsSync } from "node:fs";
import path from "node:path";
import { posixPath } from "../utils/electron";
@@ -13,7 +14,19 @@ export const selectDirectory = async () => {
export const openDirectory = async (dirPath: string) => {
// shell.openPath requires native separators, not our POSIX IPC paths.
- const res = await shell.openPath(path.normalize(dirPath));
+ const nativePath = path.normalize(dirPath);
+
+ // On Linux shell.openPath launches xdg-open without waiting for it, and
+ // drops the callback that'd settle the promise it returned (see OpenPath in
+ // Electron's platform_util_linux.cc). Awaiting it would hang this handler.
+ if (process.platform == "linux") {
+ if (!existsSync(nativePath))
+ throw new Error(`Failed to open directory ${dirPath}`);
+ void shell.openPath(nativePath);
+ return;
+ }
+
+ const res = await shell.openPath(nativePath);
// Electron resolves with an error message on failure.
if (res) throw new Error(`Failed to open directory ${dirPath}: ${res}`);
};