(targetPackPath: string, tableName: string)
| 893 | }; |
| 894 | |
| 895 | const getTableFilesForPackAndTable = async (targetPackPath: string, tableName: string) => { |
| 896 | const cacheKey = `${currentGame}|${targetPackPath}|${tableName}`; |
| 897 | const cachedFiles = tableFilesByPackAndTable.get(cacheKey); |
| 898 | if (cachedFiles) return cachedFiles; |
| 899 | |
| 900 | const targetPack = await getPackByPath(targetPackPath); |
| 901 | if (!targetPack) { |
| 902 | tableFilesByPackAndTable.set(cacheKey, []); |
| 903 | return [] as PackedFile[]; |
| 904 | } |
| 905 | |
| 906 | const tableToRead = `db\\${tableName}`; |
| 907 | if (!wasPackAlreadyRead(targetPackPath, tableToRead)) { |
| 908 | await readModsByPath([targetPackPath], { tablesToRead: [tableToRead] }, true); |
| 909 | } |
| 910 | |
| 911 | const refreshedPack = appData.packsData.find((pack) => pack.path == targetPackPath); |
| 912 | if (!refreshedPack) { |
| 913 | tableFilesByPackAndTable.set(cacheKey, []); |
| 914 | return [] as PackedFile[]; |
| 915 | } |
| 916 | |
| 917 | getPacksTableData([refreshedPack], [tableToRead]); |
| 918 | packByPath.set(targetPackPath, refreshedPack); |
| 919 | |
| 920 | const tableFiles = refreshedPack.packedFiles.filter( |
| 921 | (packedFile) => |
| 922 | packedFile.name.startsWith(`db\\${tableName}\\`) && packedFile.schemaFields && packedFile.tableSchema |
| 923 | ); |
| 924 | tableFilesByPackAndTable.set(cacheKey, tableFiles); |
| 925 | return tableFiles; |
| 926 | }; |
| 927 | |
| 928 | const ensureReverseIndexEntryFitsCache = () => { |
| 929 | while (reverseRefIndexByKey.size > maxReverseRefEntries) { |
no test coverage detected