diff --git a/src/app/desktop/utils/index.js b/src/app/desktop/utils/index.js index a075ac72..1058cfdb 100644 --- a/src/app/desktop/utils/index.js +++ b/src/app/desktop/utils/index.js @@ -5,7 +5,6 @@ import { extractFull } from 'node-7z'; import jimp from 'jimp/es'; import makeDir from 'make-dir'; import { promisify } from 'util'; -import { ipcRenderer } from 'electron'; import path from 'path'; import crypto from 'crypto'; import { exec, spawn } from 'child_process'; @@ -314,26 +313,7 @@ export const isLatestJavaDownloaded = async ( }; export const get7zPath = async () => { - // Get userData from ipc because we can't always get this from redux - let baseDir = await ipcRenderer.invoke('getExecutablePath'); - const isDev = process.env.NODE_ENV === 'development'; - if (isDev) { - baseDir = path.resolve(baseDir, '../../'); - if (process.platform === 'win32') { - baseDir = path.join(baseDir, '7zip-bin/win/x64'); - } else if (process.platform === 'linux') { - baseDir = path.join(baseDir, '7zip-bin/linux/x64'); - } else if (process.platform === 'darwin') { - baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64'); - } - } - if (process.platform === 'linux') { - return path.join(baseDir, '7za'); - } - if (process.platform === 'darwin') { - return path.resolve(baseDir, isDev ? '' : '../', '7za'); - } - return path.join(baseDir, '7za.exe'); + return '/usr/bin/7za'; }; get7zPath(); diff --git a/public/electron.js b/public/electron.js index 4d1a2e6d..0314e7fc 100644 --- a/public/electron.js +++ b/public/electron.js @@ -12,7 +12,6 @@ const { } = require('electron'); const path = require('path'); const { spawn, exec } = require('child_process'); -const { autoUpdater } = require('electron-updater'); const log = require('electron-log'); const fss = require('fs'); const { promisify } = require('util'); @@ -200,40 +199,9 @@ if ( log.log(process.env.REACT_APP_RELEASE_TYPE, app.getVersion()); const get7zPath = async () => { - let baseDir = path.dirname(app.getPath('exe')); - if (isDev) { - baseDir = path.resolve(baseDir, '../../'); - if (process.platform === 'win32') { - baseDir = path.join(baseDir, '7zip-bin/win/x64'); - } else if (process.platform === 'linux') { - baseDir = path.join(baseDir, '7zip-bin/linux/x64'); - } else if (process.platform === 'darwin') { - baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64'); - } - } - if (process.platform === 'linux') { - return path.join(baseDir, '7za'); - } - if (process.platform === 'darwin') { - return path.resolve(baseDir, isDev ? '' : '../', '7za'); - } - return path.join(baseDir, '7za.exe'); + return '/usr/bin/7za'; }; -async function patchSevenZip() { - try { - if (process.platform === 'linux' || process.platform === 'darwin') { - const sevenZipPath = await get7zPath(); - await promisify(exec)(`chmod +x "${sevenZipPath}"`); - await promisify(exec)(`chmod 755 "${sevenZipPath}"`); - } - } catch (e) { - log.error(e); - } -} - -patchSevenZip(); - function createWindow() { mainWindow = new BrowserWindow({ width: 1100, @@ -633,79 +601,3 @@ ipcMain.handle('calculateMurmur2FromPath', (e, filePath) => { }); }); }); - -// AutoUpdater - -if (process.env.REACT_APP_RELEASE_TYPE === 'setup') { - autoUpdater.autoDownload = false; - autoUpdater.allowDowngrade = - !allowUnstableReleases && app.getVersion().includes('beta'); - autoUpdater.allowPrerelease = allowUnstableReleases; - autoUpdater.setFeedURL({ - owner: 'gorilla-devs', - repo: 'GDLauncher', - provider: 'github' - }); - - autoUpdater.on('update-available', () => { - autoUpdater.downloadUpdate(); - }); - - autoUpdater.on('update-downloaded', () => { - mainWindow.webContents.send('updateAvailable'); - }); - - ipcMain.handle('checkForUpdates', () => { - autoUpdater.checkForUpdates(); - }); -} - -ipcMain.handle('installUpdateAndQuitOrRestart', async (e, quitAfterInstall) => { - const tempFolder = path.join( - path.dirname(app.getPath('exe')), - 'data', - 'temp' - ); - if (process.env.REACT_APP_RELEASE_TYPE === 'setup') { - autoUpdater.quitAndInstall(true, !quitAfterInstall); - } else { - const updaterVbs = 'updater.vbs'; - const updaterBat = 'updateLauncher.bat'; - await fs.writeFile( - path.join(tempFolder, updaterBat), - `ping 127.0.0.1 -n 1 > nul & robocopy "${path.join( - tempFolder, - 'update' - )}" "." /MOV /E${ - quitAfterInstall ? '' : ` & start "" "${app.getPath('exe')}"` - } - DEL "${path.join(tempFolder, updaterVbs)}" - DEL "%~f0" - ` - ); - - await fs.writeFile( - path.join(tempFolder, updaterVbs), - `Set WshShell = CreateObject("WScript.Shell") - WshShell.Run chr(34) & "${path.join( - tempFolder, - updaterBat - )}" & Chr(34), 0 - Set WshShell = Nothing - ` - ); - - const updateSpawn = spawn(path.join(tempFolder, updaterVbs), { - cwd: path.dirname(app.getPath('exe')), - detached: true, - shell: true, - stdio: [ - 'ignore' /* stdin */, - 'ignore' /* stdout */, - 'ignore' /* stderr */ - ] - }); - updateSpawn.unref(); - mainWindow.close(); - } -});