try catch loading spotify cache

This commit is contained in:
RemixDev 2021-12-21 15:13:48 +01:00
parent 7930ecbc95
commit 9400b0855b
No known key found for this signature in database
GPG key ID: B33962B465BDB51C

View file

@ -401,7 +401,13 @@ class Spotify extends Plugin {
let cache
try {
cache = JSON.parse(fs.readFileSync(this.configFolder+'cache.json'))
} catch {
} catch (e){
if (e.name === "SyntaxError"){
fs.writeFileSync(this.configFolder+'cache.json', JSON.stringify(
{tracks: {}, albums: {}},
null, 2
))
}
cache = {tracks: {}, albums: {}}
}
return cache