(modelDataBatch)
| 9256 | await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempt) * 1000)); |
| 9257 | continue; |
| 9258 | } |
| 9259 | throw error; |
| 9260 | } |
| 9261 | } |
| 9262 | throw lastError; |
| 9263 | }; |
| 9264 | |
| 9265 | const processFile = async (model) => { |
| 9266 | try { |
| 9267 | // Check if file exists (for regular files) or zip file exists (for zip entries) |
| 9268 | const pathInfo = parseZipPath(model.filePath); |
| 9269 | let fileExists = false; |
| 9270 | |
| 9271 | if (pathInfo.isZipEntry) { |
| 9272 | // For zip entries, check if the zip file exists |
| 9273 | fileExists = fs.existsSync(pathInfo.zipPath); |
| 9274 | } else { |
| 9275 | // For regular files, check if the file exists |
| 9276 | fileExists = fs.existsSync(model.filePath); |
| 9277 | } |
| 9278 | |
| 9279 | if (fileExists) { |
| 9280 | try { |
| 9281 | const hash = await calculateFileHashWithRetry(model.filePath); |
| 9282 | updateHash.run(hash, model.filePath); |
| 9283 | successCount++; |
| 9284 | console.log(`Hash calculated for: ${model.filePath} (${successCount} succeeded, ${failedCount} failed, ${processedCount + 1}/${modelsWithMissingHashes.length} total)`); |
| 9285 | } catch (hashError) { |
| 9286 | failedCount++; |
| 9287 | console.error(`Failed to calculate hash for ${model.filePath} after retries:`, hashError.message); |
| 9288 | } |
| 9289 | } else { |
| 9290 | console.warn(`File no longer exists: ${model.filePath}`); |
| 9291 | failedCount++; |
| 9292 | } |
| 9293 | |
| 9294 | processedCount++; |
| 9295 | |
| 9296 | // Send progress update after each file |
no test coverage detected