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

Function loadExistingOutputPackFiles

src/nodeExecutor.ts:183–225  ·  view source on GitHub ↗
(
  packPath: string,
  executionContext?: FlowExecutionContext,
)

Source from the content-addressed store, hash-verified

181});
182
183const loadExistingOutputPackFiles = async (
184 packPath: string,
185 executionContext?: FlowExecutionContext,
186): Promise<NewPackedFile[]> => {
187 const cachedOutputPack = executionContext?.outputPackByPath.get(packPath);
188 if (cachedOutputPack) {
189 return cachedOutputPack.map(cloneNewPackedFile);
190 }
191
192 if (!fs.existsSync(packPath)) {
193 return [];
194 }
195
196 const existingPack = await readPackCached(packPath, {}, executionContext);
197 const dbTableNames = existingPack.packedFiles
198 .filter((packedFile) => packedFile.name.toLowerCase().startsWith("db\\"))
199 .map((packedFile) => {
200 const parts = packedFile.name.split("\\");
201 return parts.length >= 2 ? `${parts[0]}\\${parts[1]}` : packedFile.name;
202 });
203 const uniqueTableNames = [...new Set(dbTableNames)];
204
205 if (uniqueTableNames.length > 0) {
206 getPacksTableData([existingPack], uniqueTableNames);
207 cacheTableFilesForPack(existingPack, uniqueTableNames, executionContext);
208 }
209
210 const outputFiles = existingPack.packedFiles
211 .filter((packedFile) => packedFile.schemaFields && packedFile.tableSchema)
212 .map((packedFile) => ({
213 name: packedFile.name,
214 schemaFields: packedFile.schemaFields,
215 file_size: packedFile.file_size,
216 version: packedFile.version,
217 tableSchema: packedFile.tableSchema,
218 }));
219
220 if (executionContext) {
221 executionContext.outputPackByPath.set(packPath, outputFiles.map(cloneNewPackedFile));
222 }
223
224 return outputFiles;
225};
226
227const mergeOutputPackFiles = async (
228 packPath: string,

Callers 1

mergeOutputPackFilesFunction · 0.85

Calls 4

getPacksTableDataFunction · 0.90
readPackCachedFunction · 0.85
cacheTableFilesForPackFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected