diff --git a/CLEAR-UPDATE-CACHE.md b/CLEAR-UPDATE-CACHE.md new file mode 100644 index 0000000..c72d89c --- /dev/null +++ b/CLEAR-UPDATE-CACHE.md @@ -0,0 +1,78 @@ +# Clearing Electron-Updater Cache + +To force electron-updater to re-download an update file, you need to clear the cached download. + +## Quick Method (Terminal) + +### macOS +```bash +# Remove the entire cache directory +rm -rf ~/Library/Caches/hytale-f2p-launcher + +# Or just remove pending downloads +rm -rf ~/Library/Caches/hytale-f2p-launcher/pending +``` + +### Windows +```bash +# Remove the entire cache directory +rmdir /s "%LOCALAPPDATA%\hytale-f2p-launcher-updater" + +# Or just remove pending downloads +rmdir /s "%LOCALAPPDATA%\hytale-f2p-launcher-updater\pending" +``` + +### Linux +```bash +# Remove the entire cache directory +rm -rf ~/.cache/hytale-f2p-launcher-updater + +# Or just remove pending downloads +rm -rf ~/.cache/hytale-f2p-launcher-updater/pending +``` + +## Cache Locations + +electron-updater stores downloaded updates in: + +- **macOS**: `~/Library/Caches/hytale-f2p-launcher/` +- **Windows**: `%LOCALAPPDATA%\hytale-f2p-launcher-updater\` +- **Linux**: `~/.cache/hytale-f2p-launcher-updater/` + +The cache typically contains: +- `pending/` - Downloaded update files waiting to be installed +- Metadata files about available updates + +## After Clearing + +After clearing the cache: +1. Restart the launcher +2. It will check for updates again +3. The update will be re-downloaded from scratch + +## Programmatic Method + +You can also clear the cache programmatically by adding this to your code: + +```javascript +const { autoUpdater } = require('electron-updater'); +const path = require('path'); +const fs = require('fs'); +const os = require('os'); + +function clearUpdateCache() { + const cacheDir = path.join( + os.homedir(), + process.platform === 'win32' + ? 'AppData/Local/hytale-f2p-launcher-updater' + : process.platform === 'darwin' + ? 'Library/Caches/hytale-f2p-launcher' + : '.cache/hytale-f2p-launcher-updater' + ); + + if (fs.existsSync(cacheDir)) { + fs.rmSync(cacheDir, { recursive: true, force: true }); + console.log('Update cache cleared'); + } +} +``` diff --git a/GUI/js/update.js b/GUI/js/update.js index 00393b4..bd1403c 100644 --- a/GUI/js/update.js +++ b/GUI/js/update.js @@ -10,6 +10,19 @@ class ClientUpdateManager { this.showUpdatePopup(updateInfo); }); + // Listen for electron-updater events + window.electronAPI.onUpdateAvailable((updateInfo) => { + this.showUpdatePopup(updateInfo); + }); + + window.electronAPI.onUpdateDownloadProgress((progress) => { + this.updateDownloadProgress(progress); + }); + + window.electronAPI.onUpdateDownloaded((updateInfo) => { + this.showUpdateDownloaded(updateInfo); + }); + this.checkForUpdatesOnDemand(); } @@ -33,23 +46,42 @@ class ClientUpdateManager {
Current Version: - ${updateInfo.currentVersion} + ${updateInfo.currentVersion || updateInfo.version || 'Unknown'}
New Version: - ${updateInfo.newVersion} + ${updateInfo.newVersion || updateInfo.version || 'Unknown'}
A new version of Hytale F2P Launcher is available.
- Please download the latest version to continue using the launcher. + Downloading update automatically...
- + + +