Skip to content

Commit 5187c8d

Browse files
committed
chore: move chromium session data to subfolder to declutter config dir
1 parent b3e4c77 commit 5187c8d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

electron/main/initialize-app.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Event } from 'electron';
22
import { BrowserWindow, app, dialog, shell } from 'electron';
33
import path from 'node:path';
4+
import fs from 'fs-extra';
45
import trimEnd from 'lodash-es/trimEnd.js';
56
import { VERSION } from '../common/version.js';
67
import { runInBackground } from './async/run-in-background.js';
@@ -43,6 +44,13 @@ export const initializeApp = async (): Promise<void> => {
4344
const appBuildPath = path.join(appElectronPath, 'build');
4445
const appPreloadPath = path.join(appBuildPath, 'preload');
4546

47+
// Web pages' cookies and caches are stored in the `sessionData` directory.
48+
// Chromium writes lots of files here, so to not pollute the user's app data
49+
// we put all of this in a separate directory.
50+
const appSessionDataPath = path.join(app.getPath('userData'), 'chromium');
51+
fs.ensureDirSync(appSessionDataPath);
52+
app.setPath('sessionData', appSessionDataPath);
53+
4654
// When running in production, serve the app from these paths.
4755
const prodRendererPath = path.join(appBuildPath, 'renderer');
4856
const prodAppScheme = 'app';
@@ -65,6 +73,7 @@ export const initializeApp = async (): Promise<void> => {
6573
devRendererPath,
6674
appDataPath: app.getPath('appData'),
6775
userDataPath: app.getPath('userData'),
76+
sessionDataPath: app.getPath('sessionData'),
6877
tempPath: app.getPath('temp'),
6978
logsPath: app.getPath('logs'),
7079
});

0 commit comments

Comments
 (0)