mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-31 17:45:22 +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 { isEmpty } from 'lodash'
|
||||||
import Datastore from 'nedb'
|
import Datastore from 'nedb'
|
||||||
|
import fs from 'fs'
|
||||||
import { CachedAccount } from '~/src/types/cachedAccount'
|
import { CachedAccount } from '~/src/types/cachedAccount'
|
||||||
|
|
||||||
export default class AccountCache {
|
export default class AccountCache {
|
||||||
@ -8,7 +9,16 @@ export default class AccountCache {
|
|||||||
constructor(path: string) {
|
constructor(path: string) {
|
||||||
this.db = new Datastore({
|
this.db = new Datastore({
|
||||||
filename: path,
|
filename: path,
|
||||||
autoload: true
|
autoload: true,
|
||||||
|
onload: (err: Error) => {
|
||||||
|
if (err) {
|
||||||
|
fs.unlink(path, err => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user