fix: app does not recognize GPU first launch (#2350)
This commit is contained in:
parent
aab8ee84af
commit
0415786e20
@ -2,17 +2,17 @@ import { GpuSetting, GpuSettingInfo, ResourceInfo } from '@janhq/core'
|
|||||||
import { getJanDataFolderPath, log } from '@janhq/core/node'
|
import { getJanDataFolderPath, log } from '@janhq/core/node'
|
||||||
import { mem, cpu } from 'node-os-utils'
|
import { mem, cpu } from 'node-os-utils'
|
||||||
import { exec } from 'child_process'
|
import { exec } from 'child_process'
|
||||||
import { writeFileSync, existsSync, readFileSync } from 'fs'
|
import { writeFileSync, existsSync, readFileSync, mkdirSync } from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the settings directory
|
||||||
|
**/
|
||||||
|
export const SETTINGS_DIR = path.join(getJanDataFolderPath(), 'settings')
|
||||||
/**
|
/**
|
||||||
* Path to the settings file
|
* Path to the settings file
|
||||||
**/
|
**/
|
||||||
export const GPU_INFO_FILE = path.join(
|
export const GPU_INFO_FILE = path.join(SETTINGS_DIR, 'settings.json')
|
||||||
getJanDataFolderPath(),
|
|
||||||
'settings',
|
|
||||||
'settings.json'
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default GPU settings
|
* Default GPU settings
|
||||||
@ -136,6 +136,11 @@ export const updateNvidiaInfo = async () => {
|
|||||||
try {
|
try {
|
||||||
JSON.parse(readFileSync(GPU_INFO_FILE, 'utf-8'))
|
JSON.parse(readFileSync(GPU_INFO_FILE, 'utf-8'))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (!existsSync(SETTINGS_DIR)) {
|
||||||
|
mkdirSync(SETTINGS_DIR, {
|
||||||
|
recursive: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
writeFileSync(GPU_INFO_FILE, JSON.stringify(DEFAULT_SETTINGS, null, 2))
|
writeFileSync(GPU_INFO_FILE, JSON.stringify(DEFAULT_SETTINGS, null, 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user