mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-19 12:20:20 +01:00
fix: Remove invalid account cache file when load error
This commit is contained in:
parent
1229399bc7
commit
21f2fadf85
12
src/main/cache/account.ts
vendored
12
src/main/cache/account.ts
vendored
@ -1,5 +1,6 @@
|
||||
import { isEmpty } from 'lodash'
|
||||
import Datastore from 'nedb'
|
||||
import fs from 'fs'
|
||||
import { CachedAccount } from '~/src/types/cachedAccount'
|
||||
|
||||
export default class AccountCache {
|
||||
@ -8,7 +9,16 @@ export default class AccountCache {
|
||||
constructor(path: string) {
|
||||
this.db = new Datastore({
|
||||
filename: path,
|
||||
autoload: true
|
||||
autoload: true,
|
||||
onload: (err: Error) => {
|
||||
if (err) {
|
||||
fs.unlink(path, err => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user