MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / loadFile

Method loadFile

lib/modUtilLib.js:638–660  ·  view source on GitHub ↗

* Load current cache * @returns null

()

Source from the content-addressed store, hash-verified

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

Callers 4

constructorMethod · 0.95
createNamedMultiMethod · 0.80
createNamedWindowMethod · 0.80
createMainWindowMethod · 0.80

Calls 5

debugMethod · 0.80
keysMethod · 0.80
setMethod · 0.80
warningMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected