Skip to content

Commit

Permalink
fix: update legacy path (#3328)
Browse files Browse the repository at this point in the history
  • Loading branch information
namchuai authored Aug 9, 2024
1 parent 6058764 commit 5eb1121
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions electron/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join } from 'path'
import { AppConfiguration } from '@janhq/core/node'
import os from 'os'
import { dump, load } from 'js-yaml'
import { app } from 'electron'

const configurationFileName = '.janrc'

Expand All @@ -15,7 +16,7 @@ const defaultAppConfig: AppConfiguration = {
cortexCppHost: '127.0.0.1',
cortexCppPort: 3940,
apiServerHost: '127.0.0.1',
apiServerPort: 1338
apiServerPort: 1338,
}

export async function createUserSpace(): Promise<void> {
Expand Down Expand Up @@ -90,11 +91,8 @@ export const getAppConfigurations = (): AppConfiguration => {

// Get configuration file path of the application
const getConfigurationFilePath = () => {
const homeDir = os.homedir();
const configPath = join(
homeDir,
configurationFileName,
);
const homeDir = os.homedir()
const configPath = join(homeDir, configurationFileName)
return configPath
}

Expand All @@ -117,21 +115,23 @@ export const updateAppConfiguration = (
* @returns {string} The data folder path.
*/
export const getJanDataFolderPath = (): string => {
return getAppConfigurations().dataFolderPath
return getAppConfigurations().dataFolderPath
}

// This is to support pulling legacy configs for migration purpose
export const legacyConfigs = () => {
const legacyConfigFilePath = join(
process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'] ?? '',
'settings.json'
)
const legacyConfigs = JSON.parse(readFileSync(legacyConfigFilePath, 'utf-8')) as any
const legacyConfigFilePath = join(app.getPath('userData'), 'settings.json')

const legacyConfigs = JSON.parse(
readFileSync(legacyConfigFilePath, 'utf-8')
) as any

console.debug('legacyConfigs', legacyConfigs)

return legacyConfigs
}

// This is to support pulling legacy data path for migration purpose
export const legacyDataPath = () => {
return legacyConfigs().data_path
return legacyConfigs().data_folder
}

0 comments on commit 5eb1121

Please sign in to comment.