( packPath: string, executionContext?: FlowExecutionContext, )
| 181 | }); |
| 182 | |
| 183 | const 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 | |
| 227 | const mergeOutputPackFiles = async ( |
| 228 | packPath: string, |
no test coverage detected