Skip to content

Commit

Permalink
feat: quand le lastWorkDir n'est plus présent dans store, faire un …
Browse files Browse the repository at this point in the history
…fall back sur homeDir #51
  • Loading branch information
hrenaud committed Aug 30, 2024
1 parent 6b6d6c8 commit 69888fb
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IpcMainEvent, IpcMainInvokeEvent } from 'electron'
import { ConfigData } from '../../../class/ConfigData'
import Store from 'electron-store'
import { channels } from '../../../shared/constants'
import fs from 'node:fs'
import { getMainLog } from '../../main'
import { getMainWindow } from '../../../shared/memory'
import os from 'node:os'
Expand All @@ -19,6 +20,13 @@ export const initGetWorkDir = (_event: IpcMainEvent | IpcMainInvokeEvent) => {
store.set(`lastWorkDir`, homedir)
lastWorkDir = homedir
}
try {
fs.accessSync(lastWorkDir as string)
} catch (error) {
store.set(`lastWorkDir`, homedir)
lastWorkDir = homedir
mainLog.info(`lastWorkDir unknown, fall back to homeDir`, lastWorkDir)
}

return new Promise<ConfigData>((resolve, reject) => {
try {
Expand Down

0 comments on commit 69888fb

Please sign in to comment.