(rootPath: string, folderName: string, state: BackState)
| 252 | } |
| 253 | |
| 254 | export async function loadCurationFolder(rootPath: string, folderName: string, state: BackState) { |
| 255 | const parsedMeta = await readCurationMeta(path.join(rootPath, folderName), state.platformAppPaths); |
| 256 | if (parsedMeta) { |
| 257 | const loadedCuration: LoadedCuration = { |
| 258 | folder: folderName, |
| 259 | uuid: parsedMeta.uuid || uuid(), |
| 260 | group: parsedMeta.group, |
| 261 | game: parsedMeta.game, |
| 262 | addApps: parsedMeta.addApps, |
| 263 | fpfssInfo: null, |
| 264 | thumbnail: await loadCurationIndexImage(path.join(rootPath, folderName, 'logo.png')), |
| 265 | screenshot: await loadCurationIndexImage(path.join(rootPath, folderName, 'ss.png')) |
| 266 | }; |
| 267 | const alreadyImported = (await fpDatabase.findGame(loadedCuration.uuid)) !== null; |
| 268 | const curation: CurationState = { |
| 269 | ...loadedCuration, |
| 270 | alreadyImported, |
| 271 | warnings: await genCurationWarnings(loadedCuration, state.config.flashpointPath, state.suggestions, state.languageContainer.curate, state.apiEmitters.curations.onWillGenCurationWarnings) |
| 272 | }; |
| 273 | // Try and load fpfss data |
| 274 | curation.fpfssInfo = await getCurationFpfssInfo(path.join(rootPath, folderName)); |
| 275 | state.loadedCurations.push(curation); |
| 276 | genContentTree(getContentFolderByKey(folderName, state.config.flashpointPath)).then((contentTree) => { |
| 277 | const curationIdx = state.loadedCurations.findIndex((c) => c.folder === folderName); |
| 278 | if (curationIdx >= 0) { |
| 279 | state.loadedCurations[curationIdx].contents = contentTree; |
| 280 | state.socketServer.broadcast(BackOut.CURATE_CONTENTS_CHANGE, folderName, contentTree); |
| 281 | } |
| 282 | }); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Duplicates and then loads a curation |
| 287 | export async function duplicateCuration(srcFolder: string, state: BackState): Promise<string> { |
no test coverage detected