Skip to content

[macOS] Fix install progress, install failling and no space error message #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 22, 2022
4 changes: 2 additions & 2 deletions electron/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class GOGGame extends Game {
installPlatform = 'osx'
}

const logPath = join(heroicGamesConfigPath, this.appName + '.log')
const logPath = `"${join(heroicGamesConfigPath, this.appName + '.log')}"`

const commandParts = [
'download',
Expand Down Expand Up @@ -468,7 +468,7 @@ class GOGGame extends Game {
const credentials = configStore.get('credentials') as GOGLoginData

const installPlatform = gameData.install.platform
const logPath = join(heroicGamesConfigPath, this.appName + '.log')
const logPath = `"${join(heroicGamesConfigPath, this.appName + '.log')}"`

return {
withDlcs,
Expand Down
8 changes: 6 additions & 2 deletions electron/gog/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
logWarning
} from '../logger/logger'
import { getGOGdlBin } from '../utils'
import { fallBackImage, isMac } from '../constants'
import { fallBackImage, getShell, isMac } from '../constants'
import { spawn } from 'child_process'

const apiInfoCache = new Store({ cwd: 'gog_store', name: 'api_info_cache' })
Expand Down Expand Up @@ -632,7 +632,11 @@ export async function runGogdlCommand(
}

return new Promise((res, rej) => {
const child = spawn(bin, commandParts, { cwd: dir, env: env })
const child = spawn(bin, commandParts, {
cwd: dir,
env: env,
shell: getShell()
})

const stdout = new Array<string>()
const stderr = new Array<string>()
Expand Down
6 changes: 3 additions & 3 deletions electron/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class LegendaryGame extends Game {
})
const { maxWorkers } = await GlobalConfig.get().getSettings()
const workers = maxWorkers === 0 ? '' : ` --max-workers ${maxWorkers}`
const logPath = join(heroicGamesConfigPath, this.appName + '.log')
const logPath = `"${join(heroicGamesConfigPath, this.appName + '.log')}"`

const commandParts = ['update', this.appName, workers, '-y']
const command = getLegendaryCommand(commandParts)
Expand Down Expand Up @@ -302,7 +302,7 @@ class LegendaryGame extends Game {
const withDlcs = installDlcs ? '--with-dlcs' : '--skip-dlcs'
const installSdl = sdlList.length ? this.getSdlList(sdlList) : '--skip-sdl'

const logPath = join(heroicGamesConfigPath, this.appName + '.log')
const logPath = `"${join(heroicGamesConfigPath, this.appName + '.log')}"`

const commandParts = [
'install',
Expand Down Expand Up @@ -357,7 +357,7 @@ class LegendaryGame extends Game {
const { maxWorkers } = await GlobalConfig.get().getSettings()
const workers = maxWorkers ? `--max-workers ${maxWorkers}` : ''

const logPath = join(heroicGamesConfigPath, this.appName + '.log')
const logPath = `"${join(heroicGamesConfigPath, this.appName + '.log')}"`

const commandParts = ['repair', this.appName, workers, '-y']
const command = getLegendaryCommand(commandParts)
Expand Down
7 changes: 6 additions & 1 deletion electron/legendary/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '../utils'
import {
fallBackImage,
getShell,
installed,
legendaryConfigPath,
libraryPath
Expand Down Expand Up @@ -576,7 +577,11 @@ export async function runLegendaryCommand(
}

return new Promise((res, rej) => {
const child = spawn(bin, commandParts, { cwd: dir, env: env })
const child = spawn(bin, commandParts, {
cwd: dir,
env: env,
shell: getShell()
})

const stdout = new Array<string>()
const stderr = new Array<string>()
Expand Down
15 changes: 5 additions & 10 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,12 +1108,7 @@ ipcMain.handle('updateGame', async (e, game, runner) => {
})

ipcMain.handle('requestGameProgress', async (event, appName) => {
const logPath = join(heroicGamesConfigPath, appName + '.log')
// eslint-disable-next-line no-debugger
debugger
if (!existsSync(logPath)) {
return {}
}
const logPath = `"${join(heroicGamesConfigPath, appName + '.log')}"`

const unix_progress_command = `tail ${logPath} | grep 'Progress: ' | awk '{print $5, $11}' | tail -1`
const win_progress_command = `cat ${logPath} -Tail 10 | Select-String -Pattern 'Progress:'`
Expand All @@ -1138,14 +1133,14 @@ ipcMain.handle('requestGameProgress', async (event, appName) => {
let eta = ''
let bytes = ''
if (isWindows) {
percent = progress_result.split(' ')[4]
eta = progress_result.split(' ')[10]
percent = progress_result.split(' ')[4] || ''
eta = progress_result.split(' ')[10] || ''
bytes = downloaded_result.split(' ')[5] + 'MiB'
}

if (!isWindows) {
percent = progress_result.split(' ')[0]
eta = progress_result.split(' ')[1]
percent = progress_result.split(' ')[0] || ''
eta = progress_result.split(' ')[1] || ''
bytes = downloaded_result.trim() + 'MiB'
}

Expand Down
2 changes: 1 addition & 1 deletion electron/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async function errorHandler(
const noSpaceMsg = 'Not enough available disk space'
const noCredentialsError = 'No saved credentials'
if (logPath) {
execAsync(`tail ${logPath} | grep 'disk space'`)
execAsync(`tail "${logPath}" | grep 'disk space'`)
.then(({ stdout }) => {
if (stdout.includes(noSpaceMsg)) {
logError(noSpaceMsg, LogPrefix.Backend)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "heroic",
"version": "2.3.0beta1",
"version": "2.3.0-beta-1",
"private": true,
"main": "public/main.js",
"homepage": "./",
Expand Down
5 changes: 3 additions & 2 deletions src/components/UI/Sidebar/components/SidebarLinks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export default function SidebarLinks() {
}
}, [])

console.log({ cloudsave: state?.hasCloudSave, appName, type, location })

return (
<div className="SidebarLinks Sidebar__section">
<NavLink
Expand Down Expand Up @@ -222,6 +220,9 @@ export default function SidebarLinks() {
pathname: `/settings/${appName}/wine`,
state: { ...state, runner: state?.runner }
}}
className={cx('Sidebar__item SidebarLinks__subItem', {
['active']: category === 'wine'
})}
>
Wine
</NavLink>
Expand Down