()
| 420 | } |
| 421 | |
| 422 | async getMods() { |
| 423 | if (!(await IOUtils.exists(this.modsDataFile))) { |
| 424 | await IOUtils.writeJSON(this.modsDataFile, {}); |
| 425 | |
| 426 | return {}; |
| 427 | } |
| 428 | |
| 429 | let mods = {}; |
| 430 | |
| 431 | try { |
| 432 | mods = await IOUtils.readJSON(this.modsDataFile); |
| 433 | |
| 434 | if (mods === null || typeof mods !== "object") { |
| 435 | throw new Error("Mods data file is invalid"); |
| 436 | } |
| 437 | } catch { |
| 438 | // If we have a corrupted file, reset it |
| 439 | await IOUtils.writeJSON(this.modsDataFile, {}); |
| 440 | |
| 441 | Services.wm |
| 442 | .getMostRecentWindow("navigator:browser") |
| 443 | .gZenUIManager.showToast("zen-themes-corrupted", { |
| 444 | timeout: 8000, |
| 445 | }); |
| 446 | } |
| 447 | |
| 448 | return mods; |
| 449 | } |
| 450 | |
| 451 | async getModPreferences(mod) { |
| 452 | const modPath = PathUtils.join( |
no test coverage detected