fix: update legacy path (#3328)

This commit is contained in:
NamH 2024-08-09 17:05:06 +07:00 committed by GitHub
parent 60587649c5
commit 5eb112142c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ import { join } from 'path'
import { AppConfiguration } from '@janhq/core/node' import { AppConfiguration } from '@janhq/core/node'
import os from 'os' import os from 'os'
import { dump, load } from 'js-yaml' import { dump, load } from 'js-yaml'
import { app } from 'electron'
const configurationFileName = '.janrc' const configurationFileName = '.janrc'
@ -15,7 +16,7 @@ const defaultAppConfig: AppConfiguration = {
cortexCppHost: '127.0.0.1', cortexCppHost: '127.0.0.1',
cortexCppPort: 3940, cortexCppPort: 3940,
apiServerHost: '127.0.0.1', apiServerHost: '127.0.0.1',
apiServerPort: 1338 apiServerPort: 1338,
} }
export async function createUserSpace(): Promise<void> { export async function createUserSpace(): Promise<void> {
@ -90,11 +91,8 @@ export const getAppConfigurations = (): AppConfiguration => {
// Get configuration file path of the application // Get configuration file path of the application
const getConfigurationFilePath = () => { const getConfigurationFilePath = () => {
const homeDir = os.homedir(); const homeDir = os.homedir()
const configPath = join( const configPath = join(homeDir, configurationFileName)
homeDir,
configurationFileName,
);
return configPath return configPath
} }
@ -122,16 +120,18 @@ export const getJanDataFolderPath = (): string => {
// This is to support pulling legacy configs for migration purpose // This is to support pulling legacy configs for migration purpose
export const legacyConfigs = () => { export const legacyConfigs = () => {
const legacyConfigFilePath = join( const legacyConfigFilePath = join(app.getPath('userData'), 'settings.json')
process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'] ?? '',
'settings.json' const legacyConfigs = JSON.parse(
) readFileSync(legacyConfigFilePath, 'utf-8')
const legacyConfigs = JSON.parse(readFileSync(legacyConfigFilePath, 'utf-8')) as any ) as any
console.debug('legacyConfigs', legacyConfigs)
return legacyConfigs return legacyConfigs
} }
// This is to support pulling legacy data path for migration purpose // This is to support pulling legacy data path for migration purpose
export const legacyDataPath = () => { export const legacyDataPath = () => {
return legacyConfigs().data_path return legacyConfigs().data_folder
} }