* Load current cache * @returns null
()
| 636 | * @returns null |
| 637 | */ |
| 638 | loadFile() { |
| 639 | if ( !fs.existsSync(this.#saveFileData) || !fs.existsSync(this.#saveFileIcon) || !fs.existsSync(this.#saveFileDetail) ) { |
| 640 | serveIPC.log.debug('mod-cache-manager', 'Cache Not Found, Creating') |
| 641 | return |
| 642 | } |
| 643 | |
| 644 | try { |
| 645 | const dataContents = JSON.parse(fs.readFileSync(this.#saveFileData)) |
| 646 | const iconContents = JSON.parse(fs.readFileSync(this.#saveFileIcon)) |
| 647 | const itemContents = JSON.parse(fs.readFileSync(this.#saveFileDetail)) |
| 648 | |
| 649 | for ( const key of Object.keys(dataContents) ) { |
| 650 | const keyContents = dataContents[key] |
| 651 | |
| 652 | keyContents.modDesc.iconImage = iconContents[key] ?? null |
| 653 | keyContents.includeDetail = itemContents[key] ?? null |
| 654 | |
| 655 | this.#cacheMap.set(key, keyContents) |
| 656 | } |
| 657 | } catch (err) { |
| 658 | serveIPC.log.warning('mod-cache-manager', 'Cache Error', err) |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Save current cache |
no test coverage detected