Skip to content

Commit 628951c

Browse files
committed
cache nuking
1 parent b95341d commit 628951c

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

Electron/main.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,8 @@ class promt {
29102910

29112911
function store_configuration(cbk) {
29122912
const opts = {
2913-
wolfram: server.wolfram
2913+
wolfram: server.wolfram,
2914+
version: app.getVersion()
29142915
};
29152916

29162917
fs.writeFile(path.join(appDataFolder, 'configuration.ini'), JSON.stringify(opts), function(err) {
@@ -2920,11 +2921,31 @@ function store_configuration(cbk) {
29202921
cbk();
29212922
}
29222923

2924+
function clearAllCache() {
2925+
session.defaultSession.clearStorageData();
2926+
session.defaultSession.clearCache();
2927+
console.log('Cache was nuked');
2928+
}
2929+
29232930
function load_configuration() {
2924-
if (!fs.existsSync(path.join(appDataFolder, 'configuration.ini'))) return undefined;
2931+
if (!fs.existsSync(path.join(appDataFolder, 'configuration.ini'))) {
2932+
clearAllCache();
2933+
return undefined;
2934+
}
29252935
const content = fs.readFileSync(path.join(appDataFolder, 'configuration.ini'), 'utf8');
2926-
if (content.length == 0) return undefined;
2927-
return JSON.parse(content);
2936+
if (content.length == 0) {
2937+
clearAllCache();
2938+
return undefined;
2939+
}
2940+
2941+
const parsed = JSON.parse(content);
2942+
if (!parsed) return undefined;
2943+
2944+
if (parsed.version != app.getVersion()) {
2945+
clearAllCache();
2946+
}
2947+
2948+
return parsed;
29282949
}
29292950

29302951
//checking if there is working Wolfram Kernel.

0 commit comments

Comments
 (0)