-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from mimbrero/35-corrupt-storage-data
Fix corrupt storage data on Electron update
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters