(filePath, maxRetries = 2)
| 7961 | try { |
| 7962 | // Check if this is a zip entry |
| 7963 | const pathInfo = parseZipPath(filePath); |
| 7964 | let actualFilePath = filePath; |
| 7965 | let shouldCleanup = false; |
| 7966 | |
| 7967 | if (pathInfo.isZipEntry && isMacOsResourceForkEntry(pathInfo.entryPath)) { |
| 7968 | return null; |
| 7969 | } |
| 7970 | |
| 7971 | if (pathInfo.isZipEntry) { |
| 7972 | // Extract to temp file first |
| 7973 | try { |
| 7974 | actualFilePath = await extractModelFromZip(pathInfo.zipPath, pathInfo.entryPath); |
| 7975 | shouldCleanup = true; |
| 7976 | } catch (error) { |
| 7977 | console.error('Error extracting zip entry for 3MF metadata:', error); |
| 7978 | return null; |
| 7979 | } |
| 7980 | } |
| 7981 | |
| 7982 | // Check if file exists |
| 7983 | if (!fs.existsSync(actualFilePath)) { |
| 7984 | console.error('File does not exist:', actualFilePath); |
| 7985 | return null; |
| 7986 | } |
| 7987 | |
| 7988 | const data = await fs.promises.readFile(actualFilePath); |
| 7989 | if (!isLikelyValidZipBuffer(data)) { |
| 7990 | return null; |
| 7991 | } |
| 7992 | |
| 7993 | // Use JSZip to extract the 3MF file (which is a zip file) |
| 7994 | const zip = new JSZip(); |
| 7995 | let contents; |
| 7996 | try { |
| 7997 | contents = await zip.loadAsync(data); |
no test coverage detected