fix: JRE retry button

This commit is contained in:
Fazri Gading
2026-01-25 05:18:22 +08:00
parent 9f43a32779
commit ea21fb15d6
7 changed files with 386 additions and 104 deletions

View File

@@ -423,7 +423,8 @@ async function downloadFile(url, dest, progressCallback, maxRetries = 5) {
const canRetry = (error.canRetry === false) ? false : isRetryable;
if (!canRetry || attempt === maxRetries - 1) {
retryState.canRetry = false;
// Don't set retryState.canRetry to false for max retries - user should still be able to retry manually
retryState.canRetry = error.canRetry === false ? false : true;
console.error(`Non-retryable error or max retries reached: ${error.code || error.message}`);
break;
}
@@ -439,6 +440,9 @@ async function downloadFile(url, dest, progressCallback, maxRetries = 5) {
enhancedError.retryState = retryState;
enhancedError.lastError = lastError;
enhancedError.detailedError = detailedError;
// Allow manual retry unless it's a connection lost error
enhancedError.canRetry = !lastError?.isConnectionLost && lastError?.canRetry !== false;
throw enhancedError;
}
@@ -543,6 +547,13 @@ async function retryDownload(url, dest, progressCallback, previousError = null)
additionalRetries = Math.max(2, 5 - previousError.retryState.attempts);
}
// Ensure cache directory exists before retrying
const destDir = path.dirname(dest);
if (!fs.existsSync(destDir)) {
console.log('Creating cache directory:', destDir);
fs.mkdirSync(destDir, { recursive: true });
}
try {
await downloadFile(url, dest, progressCallback, additionalRetries);
console.log('Manual retry successful');