Skip to content

Commit

Permalink
fix: Fixed backup starting while app is not active on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoelle committed Nov 9, 2021
1 parent 9ebce10 commit cd34ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/backup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import * as Path from 'path';
import { app, ipcMain, WebContents } from 'electron';
import { app, BrowserWindow, ipcMain, WebContents } from 'electron';
import dateFormat from 'dateformat';
import * as BackupIPC from './constants/BackupIPC';

Expand All @@ -19,7 +19,11 @@ export default class Backup {

private webContents: Electron.WebContents | undefined;

constructor() {
private mainWindow: BrowserWindow | null = null;

constructor(mainWindow: BrowserWindow | null) {
this.mainWindow = mainWindow;

if (!fs.existsSync(Backup.backupDir)) {
fs.mkdirSync(Backup.backupDir);
}
Expand Down Expand Up @@ -58,6 +62,9 @@ export default class Backup {
}

public makeBackup() {
if (!this.mainWindow) {
return;
}
this.deleteOldBackups();

if (this.path) {
Expand Down
2 changes: 1 addition & 1 deletion app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const createWindow = async () => {
menuBuilder.buildMenu();

new AppUpdater();
new Backup();
new Backup(mainWindow);
new Importer(mainWindow);
new Exporter();
new AutoCorrection();
Expand Down

0 comments on commit cd34ce0

Please sign in to comment.