()
| 81 | let metadataManager = new MetadataManager(); |
| 82 | |
| 83 | async function getFilesJob() { |
| 84 | updatingFiles = true; |
| 85 | console.log("Updating the file list."); |
| 86 | let oldFileCount = fileCount || 0; |
| 87 | fileCount = await getAllFiles(categoryList); |
| 88 | if (!fileCount) { |
| 89 | console.log("File update failed"); |
| 90 | return; |
| 91 | } |
| 92 | crawlTime = Date.now(); |
| 93 | console.log(`Finished updating file list. ${fileCount} found.`); |
| 94 | if (fileCount > oldFileCount) { |
| 95 | if ( |
| 96 | (await Metadata.count()) < (await metadataManager.getIGDBGamesCount()) |
| 97 | ) { |
| 98 | await metadataManager.syncAllMetadata(); |
| 99 | } |
| 100 | await metadataManager.matchAllMetadata(); |
| 101 | metadataMatchCount = await File.count({ |
| 102 | where: { detailsId: { [Op.ne]: null } }, |
| 103 | }); |
| 104 | if (process.env.DB_KEYWORD_OPTIMIZER === "1") { |
| 105 | await optimizeDatabaseKws(); |
| 106 | } |
| 107 | } |
| 108 | //this is less important and needs to run last. |
| 109 | if (fileCount > oldFileCount && (await Metadata.count())) { |
| 110 | metadataManager.matchAllMetadata(true); |
| 111 | } |
| 112 | metadataMatchCount = await File.count({ |
| 113 | where: { detailsId: { [Op.ne]: null } }, |
| 114 | }); |
| 115 | updatingFiles = false; |
| 116 | } |
| 117 | |
| 118 | async function updateMetadata() { |
| 119 | if (updatingFiles) return; |
no test coverage detected