Skip to content

Commit

Permalink
feat: crashlogs, proper exit, bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Dec 10, 2024
1 parent 14f0854 commit 73d9b69
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 51 deletions.
68 changes: 34 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@filen/desktop",
"version": "3.0.40",
"buildNumber": 340,
"version": "3.0.41",
"buildNumber": 341,
"description": "Filen Desktop Client",
"author": "Filen Cloud Dienste UG (haftungsbeschränkt) <[email protected]>",
"main": "dist/index.js",
Expand Down Expand Up @@ -65,12 +65,12 @@
"yaml": "^2.6.0"
},
"dependencies": {
"@filen/network-drive": "^0.9.39",
"@filen/s3": "^0.2.49",
"@filen/sdk": "^0.1.189",
"@filen/sync": "^0.1.91",
"@filen/web": "^0.1.81",
"@filen/webdav": "^0.2.63",
"@filen/network-drive": "^0.9.40",
"@filen/s3": "^0.2.50",
"@filen/sdk": "^0.1.191",
"@filen/sync": "^0.1.93",
"@filen/web": "^0.1.82",
"@filen/webdav": "^0.2.64",
"axios": "^0.28.1",
"cors": "^2.8.5",
"electron-updater": "^6.4.0-alpha.1",
Expand Down
27 changes: 22 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, shell, dialog } from "electron"
import { app, BrowserWindow, shell, dialog, crashReporter } from "electron"
import pathModule from "path"
import IPC from "./ipc"
import FilenSDK from "@filen/sdk"
Expand All @@ -15,6 +15,7 @@ import serveProd from "./lib/serve"
import WindowState from "./lib/windowState"
import Status from "./lib/status"
import Options from "./lib/options"
import os from "os"

if (IS_ELECTRON) {
// Needs to be here, otherwise Chromium's FileSystemAccess API won't work. Waiting for the electron team to fix it.
Expand Down Expand Up @@ -50,6 +51,7 @@ export class FilenDesktop {
public minimizeToTray: boolean = false
public status: Status
public options: Options
public shouldExitOnQuit: boolean = false

/**
* Creates an instance of FilenDesktop.
Expand All @@ -59,6 +61,21 @@ export class FilenDesktop {
* @public
*/
public constructor() {
crashReporter.start({
submitURL: undefined,
productName: "io.filen.desktop",
uploadToServer: false,
ignoreSystemCrashHandler: false,
rateLimit: false,
compress: false,
globalExtra: {
cpus: os.cpus().length.toString(),
ram: os.totalmem().toString(),
platform: os.platform(),
release: os.release()
}
})

this.serve = serveProd()
this.windowState = new WindowState()
this.sdk = new FilenSDK()
Expand Down Expand Up @@ -121,9 +138,9 @@ export class FilenDesktop {
this.initializeSDK()

app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit()
}
this.shouldExitOnQuit = true

app.exit(0)
})

app.on("second-instance", () => {
Expand Down Expand Up @@ -315,7 +332,7 @@ export class FilenDesktop {
})

this.driveWindow?.on("close", e => {
if ((process.platform === "darwin" || this.minimizeToTray) && !this.driveWindow?.isMinimized()) {
if ((process.platform === "darwin" || this.minimizeToTray) && !this.driveWindow?.isMinimized() && !this.shouldExitOnQuit) {
e.preventDefault()

this.driveWindow?.minimize()
Expand Down
7 changes: 6 additions & 1 deletion src/ipc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class IPC {
this.didCallRestart = true

app.relaunch()
app.quit()
app.exit(0)
})

ipcMain.handle("setConfig", async (_, config: FilenDesktopConfig): Promise<void> => {
Expand Down Expand Up @@ -406,6 +406,11 @@ export class IPC {
}

const logsPath = await filenLogsPath()

await fs.copy(app.getPath("crashDumps"), pathModule.join(logsPath, "crashDumps"), {
overwrite: true
})

const dir = await getLocalDirectorySize(logsPath)

if (dir.items === 0) {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export class Updater {
throw new Error("No update available to install.")
}

this.desktop.shouldExitOnQuit = true

this.desktop.logger.log("info", "Installing update")

app.removeAllListeners("window-all-closed")
Expand Down Expand Up @@ -163,7 +165,7 @@ export class Updater {

if (process.platform === "win32") {
setTimeout(() => {
app.quit()
app.exit(0)
}, 1000)
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Worker {
} finally {
this.didQuitApp = true

app.quit()
app.exit(0)
}
})
}
Expand Down Expand Up @@ -93,7 +93,16 @@ export class Worker {

this.worker = new WorkerThread(pathModule.join(__dirname, !isDev ? "worker.js" : "worker.dev.js"))

this.worker.on("error", reject)
this.worker.on("error", err => {
this.desktop.logger.log("error", err, "worker.onError")
this.desktop.logger.log("error", err)

reject(err)
})

this.worker.on("exit", code => {
this.desktop.logger.log("error", `Worker exited with code ${code}.`)
})

if (isDev) {
this.worker.stderr.on("data", chunk => {
Expand Down

0 comments on commit 73d9b69

Please sign in to comment.