Skip to content

Commit

Permalink
fix: use data folder on portable app Eugeny#9243
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Nov 18, 2023
1 parent 3d83bc6 commit ae21878
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion app/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { app, ipcMain, Menu, dialog } from 'electron'

// Portable verison: set userData path
import './portable'

// set defaults of environment variables
import 'dotenv/config'
process.env.TABBY_PLUGINS ??= ''
process.env.TABBY_CONFIG_DIRECTORY ??= app.getPath('userData')


import 'v8-compile-cache'
import './portable'

import 'source-map-support/register'
import './sentry'
import './lru'
Expand Down
13 changes: 7 additions & 6 deletions app/lib/portable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import * as path from 'path'
import * as fs from 'fs'
import * as electron from 'electron'

const appPath = path.dirname(electron.app.getPath('exe'))

const portableData = path.join(appPath, 'data')
if (fs.existsSync(portableData)) {
console.log('reset user data to ' + portableData)
electron.app.setPath('userData', portableData)
const isPortable = !!process.env.PORTABLE_EXECUTABLE_FILE
if (isPortable) {
const portableData = path.join(process.env.PORTABLE_EXECUTABLE_DIR, 'data')
if (fs.existsSync(portableData)) {
console.log('reset user data to ' + portableData)
electron.app.setPath('userData', portableData)
}
}

0 comments on commit ae21878

Please sign in to comment.