Skip to content

Commit

Permalink
Merge branch 'fix/factory-reset-windows' into release-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Jul 10, 2024
2 parents 6e613ec + ad8f7c4 commit 7798d42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/main/filesystem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App } from 'electron';
import { type App, session } from 'electron';
import fs from 'fs';
import path from 'path';

Expand Down Expand Up @@ -200,8 +200,13 @@ export class LauncherFileSystem {
return fs.existsSync(path.join(this.keystoreDir, 'lair-keystore-config.yaml'));
};

factoryReset(keepLogs = false) {
async factoryReset(keepLogs = false) {
if (keepLogs) throw new Error('Keeping logs across factory reset is currently not supported.');
await session.defaultSession.clearCache();
await session.defaultSession.clearStorageData();
await session.defaultSession.clearAuthCache();
await session.defaultSession.clearCodeCaches({});
await session.defaultSession.clearHostResolverCache();
deleteRecursively(this.profileDataDir);
}
}
Expand Down Expand Up @@ -229,8 +234,6 @@ export function deleteRecursively(root: string) {
console.log('Removing files and subfolders.');
const filesAndSubFolders = fs.readdirSync(root);
filesAndSubFolders.forEach((file) => deleteRecursively(path.join(root, file)));
} else {
console.log('fs.statSync(root): ', fs.statSync(root));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export async function factoryResetUtility({
console.log('factory reset...');

// 3. Remove all data
launcherFileSystem.factoryReset();
await launcherFileSystem.factoryReset();

// 4. Relaunch
const options: Electron.RelaunchOptions = {
Expand Down

0 comments on commit 7798d42

Please sign in to comment.