Skip to content

Commit

Permalink
Merge pull request #36 from mimbrero/35-corrupt-storage-data
Browse files Browse the repository at this point in the history
Fix corrupt storage data on Electron update
  • Loading branch information
mimbrero authored Oct 12, 2022
2 parents c4ce29f + e91b55e commit 7d09dac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/fix/electron-21-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { app, session } from "electron";
import fs from "fs";
import path from "path";
import Settings from "../settings";
import Fix from "./fix";

const settings = new Settings("fixes");

/**
* Fixes #35, clears corrupt storage data.
*/
export default class Electron21Fix extends Fix {

public override beforeLoad() {
if (!settings.get("electron-21", false)) {
console.info("Clearing storage data...");

// Electron.Session#clearStorageData isn't clearing service workers :/
fs.rmSync(path.join(app.getPath("userData"), "Service Worker"), {
recursive: true,
force: true
});

session.defaultSession.clearStorageData();

settings.set("electron-21", true);
}
}
}
2 changes: 2 additions & 0 deletions src/whatsapp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { app, BrowserWindow, ipcMain, shell } from "electron";
import path from "path";
import ChromeVersionFix from "./fix/chrome-version-fix";
import Electron21Fix from "./fix/electron-21-fix";
import HotkeyModule from "./module/hotkey-module";
import ModuleManager from "./module/module-manager";
import TrayModule from "./module/tray-module";
Expand Down Expand Up @@ -29,6 +30,7 @@ export default class WhatsApp {
});

this.moduleManager = new ModuleManager([
new Electron21Fix(),
new HotkeyModule(this, this.window),
new TrayModule(this, this.window),
new WindowSettingsModule(this, this.window),
Expand Down

0 comments on commit 7d09dac

Please sign in to comment.