mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 16:21:49 -03:00
Fix SHA512 checksum mismatch handling - clear cache and retry automatically
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -33,6 +33,7 @@ jobs:
|
|||||||
name: linux-builds
|
name: linux-builds
|
||||||
path: |
|
path: |
|
||||||
dist/*.AppImage
|
dist/*.AppImage
|
||||||
|
dist/*.AppImage.blockmap
|
||||||
dist/*.deb
|
dist/*.deb
|
||||||
dist/*.rpm
|
dist/*.rpm
|
||||||
dist/*.pacman
|
dist/*.pacman
|
||||||
@@ -53,6 +54,7 @@ jobs:
|
|||||||
name: windows-builds
|
name: windows-builds
|
||||||
path: |
|
path: |
|
||||||
dist/*.exe
|
dist/*.exe
|
||||||
|
dist/*.exe.blockmap
|
||||||
dist/latest.yml
|
dist/latest.yml
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
|
|||||||
@@ -265,6 +265,8 @@ class ClientUpdateManager {
|
|||||||
let message = 'Auto-update is not available. ';
|
let message = 'Auto-update is not available. ';
|
||||||
if (errorInfo.isMacSigningError) {
|
if (errorInfo.isMacSigningError) {
|
||||||
message = 'This app requires code signing for automatic updates.';
|
message = 'This app requires code signing for automatic updates.';
|
||||||
|
} else if (errorInfo.isLinuxInstallError) {
|
||||||
|
message = 'Auto-installation requires root privileges. Please download and install the update manually using your package manager.';
|
||||||
} else if (errorInfo.message) {
|
} else if (errorInfo.message) {
|
||||||
message = errorInfo.message;
|
message = errorInfo.message;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
const { autoUpdater } = require('electron-updater');
|
const { autoUpdater } = require('electron-updater');
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const logger = require('./logger');
|
const logger = require('./logger');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
class AppUpdater {
|
class AppUpdater {
|
||||||
constructor(mainWindow) {
|
constructor(mainWindow) {
|
||||||
@@ -98,6 +101,21 @@ class AppUpdater {
|
|||||||
return; // Don't show error UI for network issues
|
return; // Don't show error UI for network issues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle SHA512 checksum mismatch - this can happen during updates, just retry
|
||||||
|
const isChecksumError = err.code === 'ERR_CHECKSUM_MISMATCH' ||
|
||||||
|
errorMessage.includes('sha512') ||
|
||||||
|
errorMessage.includes('checksum') ||
|
||||||
|
errorMessage.includes('mismatch');
|
||||||
|
|
||||||
|
if (isChecksumError) {
|
||||||
|
console.warn('SHA512 checksum mismatch detected - clearing cache and will retry automatically. This is normal during updates.');
|
||||||
|
// Clear the update cache and let it re-download
|
||||||
|
this.clearUpdateCache();
|
||||||
|
|
||||||
|
// Don't show error UI - just log and let it retry automatically on next check
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if this is a critical error that prevents auto-update
|
// Determine if this is a critical error that prevents auto-update
|
||||||
const isCriticalError = this.isCriticalUpdateError(err);
|
const isCriticalError = this.isCriticalUpdateError(err);
|
||||||
|
|
||||||
@@ -125,6 +143,34 @@ class AppUpdater {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linux-specific: Handle installation permission errors
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
const errorMessage = err.message?.toLowerCase() || '';
|
||||||
|
const errorStack = err.stack?.toLowerCase() || '';
|
||||||
|
const isInstallError = errorMessage.includes('pkexec') ||
|
||||||
|
errorMessage.includes('gksudo') ||
|
||||||
|
errorMessage.includes('kdesudo') ||
|
||||||
|
errorMessage.includes('setuid root') ||
|
||||||
|
errorMessage.includes('exited with code 127') ||
|
||||||
|
errorStack.includes('pacmanupdater') ||
|
||||||
|
errorStack.includes('doinstall') ||
|
||||||
|
errorMessage.includes('installation failed');
|
||||||
|
|
||||||
|
if (isInstallError) {
|
||||||
|
console.warn('Linux installation error: Package installation requires root privileges. Manual installation required.');
|
||||||
|
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||||
|
this.mainWindow.webContents.send('update-error', {
|
||||||
|
message: 'Auto-installation requires root privileges. Please download and install the update manually.',
|
||||||
|
code: err.code || 'ERR_LINUX_INSTALL_PERMISSION',
|
||||||
|
isLinuxInstallError: true,
|
||||||
|
requiresManualDownload: true,
|
||||||
|
updateVersion: this.updateVersion
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// macOS-specific: Handle unsigned app errors gracefully
|
// macOS-specific: Handle unsigned app errors gracefully
|
||||||
if (process.platform === 'darwin' && err.code === 2) {
|
if (process.platform === 'darwin' && err.code === 2) {
|
||||||
console.warn('macOS update error: App may not be code-signed. Auto-update requires code signing.');
|
console.warn('macOS update error: App may not be code-signed. Auto-update requires code signing.');
|
||||||
@@ -242,6 +288,26 @@ class AppUpdater {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearUpdateCache() {
|
||||||
|
try {
|
||||||
|
// Get the cache directory based on platform
|
||||||
|
const cacheDir = process.platform === 'darwin'
|
||||||
|
? path.join(os.homedir(), 'Library', 'Caches', `${app.getName()}-updater`)
|
||||||
|
: process.platform === 'win32'
|
||||||
|
? path.join(os.homedir(), 'AppData', 'Local', `${app.getName()}-updater`)
|
||||||
|
: path.join(os.homedir(), '.cache', `${app.getName()}-updater`);
|
||||||
|
|
||||||
|
if (fs.existsSync(cacheDir)) {
|
||||||
|
fs.rmSync(cacheDir, { recursive: true, force: true });
|
||||||
|
console.log('Update cache cleared successfully');
|
||||||
|
} else {
|
||||||
|
console.log('Update cache directory does not exist');
|
||||||
|
}
|
||||||
|
} catch (cacheError) {
|
||||||
|
console.warn('Could not clear update cache:', cacheError.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isCriticalUpdateError(err) {
|
isCriticalUpdateError(err) {
|
||||||
// Check for errors that prevent auto-update
|
// Check for errors that prevent auto-update
|
||||||
const errorMessage = err.message?.toLowerCase() || '';
|
const errorMessage = err.message?.toLowerCase() || '';
|
||||||
@@ -277,6 +343,16 @@ class AppUpdater {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Linux installation errors (pkexec, sudo issues)
|
||||||
|
if (process.platform === 'linux' && (
|
||||||
|
errorMessage.includes('pkexec') ||
|
||||||
|
errorMessage.includes('setuid root') ||
|
||||||
|
errorMessage.includes('exited with code 127') ||
|
||||||
|
errorMessage.includes('gksudo') ||
|
||||||
|
errorMessage.includes('kdesudo'))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// File system errors (but not "not found" for metadata files - handled above)
|
// File system errors (but not "not found" for metadata files - handled above)
|
||||||
if (errorMessage.includes('enoent') || errorMessage.includes('cannot find')) {
|
if (errorMessage.includes('enoent') || errorMessage.includes('cannot find')) {
|
||||||
// Only if it's not about metadata files
|
// Only if it's not about metadata files
|
||||||
@@ -285,10 +361,14 @@ class AppUpdater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic critical error codes
|
// Generic critical error codes (but not checksum errors - those are handled separately)
|
||||||
if (errorCode && (errorCode >= 100 ||
|
if (errorCode && (errorCode >= 100 ||
|
||||||
errorCode === 'ERR_UPDATER_INVALID_RELEASE_FEED' ||
|
errorCode === 'ERR_UPDATER_INVALID_RELEASE_FEED' ||
|
||||||
errorCode === 'ERR_UPDATER_CHANNEL_FILE_NOT_FOUND')) {
|
errorCode === 'ERR_UPDATER_CHANNEL_FILE_NOT_FOUND')) {
|
||||||
|
// Don't treat checksum errors as critical - they're handled separately
|
||||||
|
if (errorCode === 'ERR_CHECKSUM_MISMATCH') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user