Fix issue with corrupted themes data file

This commit is contained in:
mr. M 2024-10-15 16:10:25 +02:00
parent 3dc7738737
commit 83a612c6e5
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB

View file

@ -31,7 +31,22 @@ var ZenThemesCommon = {
await IOUtils.writeJSON(this.themesDataFile, {});
}
this.themes = await IOUtils.readJSON(this.themesDataFile);
try {
this.themes = await IOUtils.readJSON(this.themesDataFile);
} catch (e) {
// If we have a corrupted file, reset it
await IOUtils.writeJSON(this.themesDataFile, {});
this.themes = {};
gNotificationBox.appendNotification(
"zen-themes-corrupted",
{
label: { "l10n-id": "zen-themes-corrupted" },
image: "chrome://browser/skin/notification-icons/persistent-storage-blocked.svg",
priority: gNotificationBox.PRIORITY_INFO_MEDIUM,
},
[]
);
}
}
return this.themes;
},