From 4822f9580270374f9a4d7018af41cd05a337b8d0 Mon Sep 17 00:00:00 2001 From: Pedram Amini Date: Thu, 18 Dec 2025 00:35:49 -0600 Subject: [PATCH] # CHANGES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added latest.yml files to release artifacts for auto-updater ๐Ÿš€ - Enhanced pre-download update check for better reliability โœจ - Improved error handling with detailed logging messages ๐Ÿ›ก๏ธ - Fixed update flow by checking versions before downloading ๐Ÿ”ง - Added development mode stub handlers for testing ๐Ÿงช - Prevented confusing errors in development environment ๐Ÿ’ก - Included platform-specific update manifest files ๐Ÿ“ฆ - Strengthened auto-updater with validation checks โœ… - Better error messages for failed update attempts ๐Ÿ“ - Smoother update experience with proper state management ๐ŸŽฏ --- .github/workflows/release.yml | 3 +++ src/main/auto-updater.ts | 14 ++++++++++++++ src/main/index.ts | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95ad31f2..14107741 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -170,6 +170,7 @@ jobs: release/*.zip release/*-mac.zip release/*-mac-*.zip + release/latest-mac.yml if-no-files-found: error retention-days: 5 @@ -180,6 +181,7 @@ jobs: name: maestro-windows path: | release/*.exe + release/latest.yml if-no-files-found: error retention-days: 5 @@ -193,6 +195,7 @@ jobs: release/*.deb release/*.rpm release/*.snap + release/latest-linux.yml if-no-files-found: warn retention-days: 5 diff --git a/src/main/auto-updater.ts b/src/main/auto-updater.ts index d2e2541d..da774a4c 100644 --- a/src/main/auto-updater.ts +++ b/src/main/auto-updater.ts @@ -96,12 +96,26 @@ function setupIpcHandlers(): void { // Download update ipcMain.handle('updates:download', async () => { try { + // First, check for updates with electron-updater to tell it which version to download + // This is required because the UI uses the GitHub API check, not electron-updater's check + logger.info('Checking for updates before download...', 'AutoUpdater'); + const checkResult = await autoUpdater.checkForUpdates(); + + if (!checkResult || !checkResult.updateInfo) { + logger.error('No update found during pre-download check', 'AutoUpdater'); + currentStatus = { status: 'error', error: 'No update available to download' }; + sendStatusToRenderer(); + return { success: false, error: 'No update available to download' }; + } + + logger.info(`Found update ${checkResult.updateInfo.version}, starting download...`, 'AutoUpdater'); currentStatus = { status: 'downloading', progress: { percent: 0, bytesPerSecond: 0, total: 0, transferred: 0, delta: 0 } }; sendStatusToRenderer(); await autoUpdater.downloadUpdate(); return { success: true }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + logger.error(`Download failed: ${errorMessage}`, 'AutoUpdater'); currentStatus = { status: 'error', error: errorMessage }; sendStatusToRenderer(); return { success: false, error: errorMessage }; diff --git a/src/main/index.ts b/src/main/index.ts index d98abd3d..beaea6f8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -556,6 +556,21 @@ function createWindow() { if (process.env.NODE_ENV !== 'development') { initAutoUpdater(mainWindow); logger.info('Auto-updater initialized', 'Window'); + } else { + // Register stub handlers in development mode so users get a helpful error + ipcMain.handle('updates:download', async () => { + return { success: false, error: 'Auto-update is disabled in development mode. Please check update first.' }; + }); + ipcMain.handle('updates:install', async () => { + logger.warn('Auto-update install called in development mode', 'AutoUpdater'); + }); + ipcMain.handle('updates:getStatus', async () => { + return { status: 'idle' as const }; + }); + ipcMain.handle('updates:checkAutoUpdater', async () => { + return { success: false, error: 'Auto-update is disabled in development mode' }; + }); + logger.info('Auto-updater disabled in development mode (stub handlers registered)', 'Window'); } }