MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / getTableFilesForPackAndTable

Function getTableFilesForPackAndTable

src/DBClone.ts:895–926  ·  view source on GitHub ↗
(targetPackPath: string, tableName: string)

Source from the content-addressed store, hash-verified

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) {

Callers 3

getReverseRefIndexFunction · 0.85

Calls 6

readModsByPathFunction · 0.90
getPacksTableDataFunction · 0.90
getPackByPathFunction · 0.85
wasPackAlreadyReadFunction · 0.85
getPackFromCacheOrReadFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected