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
51 changes: 2 additions & 49 deletions electron/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ const installedGamesStore = new Store({
name: 'installed'
})

function verifyProgress(stderr: string): boolean {
let index = stderr.lastIndexOf('\n')
index = stderr.lastIndexOf('\n', index - 1)
const status = stderr.substring(index)
const match = status.match(/Progress: ([0-9.]+) ([0-9]+)\/([0-9]+)/)
return match !== null && 100 === Number(match[1]) && match[2] === match[3]
}

class GOGGame extends Game {
public appName: string
public window = BrowserWindow.getAllWindows()[0]
Expand Down Expand Up @@ -145,7 +137,8 @@ class GOGGame extends Game {
'--platform',
installPlatform,
`--path=${path}`,
`--token=${credentials.access_token}`,
`--token`,
`${credentials.access_token}`,
withDlcs,
`--lang=${installLanguage}`,
workers
Expand All @@ -164,19 +157,6 @@ class GOGGame extends Game {
return { status: 'error' }
}

const success = verifyProgress(res.stderr)
if (!success) {
logError(
[
'Failed to install',
`${this.appName}:`,
'Command aborted unexpectedly'
],
LogPrefix.Gog
)
return { status: 'error' }
}

// Installation succeded
// Save new game info to installed games store
const installInfo = await this.getInstallInfo()
Expand Down Expand Up @@ -283,18 +263,6 @@ class GOGGame extends Game {
)
}

const success = verifyProgress(res.stderr)
if (!success) {
logError(
[
'Failed to update',
`${this.appName}:`,
'Command aborted unexpectedly'
],
LogPrefix.Gog
)
}

return res
}

Expand Down Expand Up @@ -412,21 +380,6 @@ class GOGGame extends Game {
return { status: 'error' }
}

const success = verifyProgress(res.stderr)
if (!success) {
logError(
[
'Failed to update',
`${this.appName}:`,
'Command aborted unexpectedly'
],
LogPrefix.Gog
)
return { status: 'error' }
}

// Update was successful

const installedArray = installedGamesStore.get(
'installed'
) as InstalledInfo[]
Expand Down
6 changes: 5 additions & 1 deletion electron/gog/library.ts
Original file line number Diff line number Diff line change
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: isMac
})

const stdout = new Array<string>()
const stderr = new Array<string>()
Expand Down
7 changes: 6 additions & 1 deletion electron/legendary/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import {
fallBackImage,
installed,
isMac,
legendaryConfigPath,
libraryPath
} from '../constants'
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: isMac
})

const stdout = new Array<string>()
const stderr = new Array<string>()
Expand Down
16 changes: 8 additions & 8 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,10 +1108,10 @@ 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)) {
const logPath = `"${join(heroicGamesConfigPath, appName + '.log')}"`

// existsync doesnt work when the path has quotes in it
if (!existsSync(logPath.replaceAll('"', ''))) {
return {}
}

Expand All @@ -1138,14 +1138,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
91 changes: 45 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,39 +125,38 @@
}
},
"dependencies": {
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@fontsource/cabin": "^4.5.1",
"@fontsource/rubik": "^4.5.1",
"@fortawesome/fontawesome-svg-core": "^1.3.0-beta3",
"@fortawesome/free-brands-svg-icons": "^6.0.0-beta3",
"@fortawesome/free-solid-svg-icons": "^6.0.0-beta3",
"@fortawesome/react-fontawesome": "^0.1.16",
"@mui/icons-material": "^5.3.1",
"@mui/material": "^5.4.0",
"axios": "^0.21.1",
"classnames": "^2.2.6",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@fontsource/cabin": "^4.5.5",
"@fontsource/rubik": "^4.5.6",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.2",
"axios": "^0.26.1",
"classnames": "^2.3.1",
"discord-rich-presence-typescript": "^0.0.8",
"electron-store": "^8.0.1",
"electron-updater": "^5.0.1",
"graceful-fs": "^4.2.8",
"heroic-wine-downloader": "^1.2.2",
"i18next": "^21.6.6",
"graceful-fs": "^4.2.10",
"heroic-wine-downloader": "^1.2.3",
"i18next": "^21.6.16",
"i18next-fs-backend": "^1.1.4",
"i18next-http-backend": "^1.3.1",
"ini": "^2.0.0",
"i18next-http-backend": "^1.4.0",
"ini": "^3.0.0",
"plist": "^3.0.5",
"pretty-bytes": "^5.6.0",
"react": "^18.0.0",
"react-contextmenu": "^2.14.0",
"react-dom": "^18.0.0",
"react-i18next": "^11.15.3",
"react-router-dom": "^5.2.0",
"react-scripts": "^5.0.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-i18next": "^11.16.7",
"react-router-dom": "^5.3.1",
"react-scripts": "^5.0.1",
"simple-keyboard": "^3.4.24",
"source-map-support": "^0.5.21",
"systeminformation": "^5.10.7",
"tslib": "^2.3.1"
"systeminformation": "^5.11.14",
"tslib": "^2.4.0"
},
"scripts": {
"start": "DISABLE_ESLINT_PLUGIN=true nf start -p 3000 && electron-start",
Expand Down Expand Up @@ -195,33 +194,33 @@
},
"devDependencies": {
"@testing-library/dom": "^7.31.0",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^13.1.9",
"@types/classnames": "^2.2.11",
"@types/i18next-fs-backend": "^1.0.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.1.1",
"@testing-library/user-event": "^14.1.1",
"@types/classnames": "^2.3.1",
"@types/i18next-fs-backend": "^1.1.2",
"@types/ini": "^1.3.31",
"@types/jest": "^26.0.23",
"@types/node": "^17.0.10",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"@types/plist": "^3.0.2",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"electron": "^18.0.3",
"@types/react": "^18.0.6",
"@types/react-dom": "^18.0.2",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"electron": "^18.1.0",
"electron-builder": "^23.0.3",
"electron-devtools-installer": "^3.2.0",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.24.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.29.4",
"foreman": "^3.0.1",
"husky": "^7.0.4",
"i18next-parser": "^5.4.0",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.2",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
"i18next-parser": "^6.3.0",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
},
"browserslist": {
"production": [
Expand Down
9 changes: 8 additions & 1 deletion src/components/UI/Dialog/components/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { SyntheticEvent, useCallback, useEffect, useRef } from 'react'
import React, {
ReactNode,
SyntheticEvent,
useCallback,
useEffect,
useRef
} from 'react'

export interface DialogProps {
className?: string
children: ReactNode
onClose: () => void
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/UI/Dialog/components/DialogContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react'
import React, { ReactNode } from 'react'

export const DialogContent: React.FC = ({ children }) => {
interface Props {
children: ReactNode
}

export const DialogContent: React.FC<Props> = ({ children }: Props) => {
return <div className="Dialog__content">{children}</div>
}
8 changes: 6 additions & 2 deletions src/components/UI/Dialog/components/DialogFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react'
import React, { ReactNode } from 'react'

export const DialogFooter: React.FC = ({ children }) => {
interface Props {
children: ReactNode
}

export const DialogFooter: React.FC<Props> = ({ children }: Props) => {
return <div className="Dialog__footer">{children}</div>
}
3 changes: 2 additions & 1 deletion src/components/UI/Dialog/components/DialogHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { faXmark } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React from 'react'
import React, { ReactNode } from 'react'

export interface DialogHeaderProps {
onClose: () => void
children: ReactNode
}

export const DialogHeader: React.FC<DialogHeaderProps> = ({
Expand Down
1 change: 1 addition & 0 deletions src/components/UI/FormControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { ReactNode } from 'react'
import './index.css'

export interface FormControlProps {
children: ReactNode
className?: string
select?: boolean
segmented?: boolean
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
Loading