1
1
import type { Event } from 'electron' ;
2
2
import { BrowserWindow , app , dialog , shell } from 'electron' ;
3
3
import path from 'node:path' ;
4
+ import fs from 'fs-extra' ;
4
5
import trimEnd from 'lodash-es/trimEnd.js' ;
5
6
import { VERSION } from '../common/version.js' ;
6
7
import { runInBackground } from './async/run-in-background.js' ;
@@ -43,6 +44,13 @@ export const initializeApp = async (): Promise<void> => {
43
44
const appBuildPath = path . join ( appElectronPath , 'build' ) ;
44
45
const appPreloadPath = path . join ( appBuildPath , 'preload' ) ;
45
46
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
+
46
54
// When running in production, serve the app from these paths.
47
55
const prodRendererPath = path . join ( appBuildPath , 'renderer' ) ;
48
56
const prodAppScheme = 'app' ;
@@ -65,6 +73,7 @@ export const initializeApp = async (): Promise<void> => {
65
73
devRendererPath,
66
74
appDataPath : app . getPath ( 'appData' ) ,
67
75
userDataPath : app . getPath ( 'userData' ) ,
76
+ sessionDataPath : app . getPath ( 'sessionData' ) ,
68
77
tempPath : app . getPath ( 'temp' ) ,
69
78
logsPath : app . getPath ( 'logs' ) ,
70
79
} ) ;
0 commit comments