mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-09 03:07:46 +08:00
fix: validate admin settings file target (#894)
This commit is contained in:
@@ -125,7 +125,12 @@ let writableCache: boolean | null = null
|
||||
export function isSettingsWritable(): boolean {
|
||||
if (writableCache !== null) return writableCache
|
||||
try {
|
||||
const dir = path.dirname(getSettingsPath())
|
||||
const filePath = getSettingsPath()
|
||||
if (fs.existsSync(filePath) && !fs.statSync(filePath).isFile()) {
|
||||
writableCache = false
|
||||
return writableCache
|
||||
}
|
||||
const dir = path.dirname(filePath)
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
fs.accessSync(dir, fs.constants.W_OK)
|
||||
writableCache = true
|
||||
|
||||
Reference in New Issue
Block a user