Skip to content

[FIX] Issues with Epic Login and refresh Library #1073

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 9 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion electron/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ function fixPathWithSpaces(path: string) {
}

// for windows, it depend of the build
return should_not_escape(...windows_version_regex.exec(version).splice(1))
const fixedPath = should_not_escape(
...windows_version_regex.exec(version).splice(1)
)
? // on major version, no need to escape anymore
// https://support.microsoft.com/en-us/help/4467268/url-encoded-unc-paths-not-url-decoded-in-windows-10-version-1803-later
path
: // on older version, replace space with symbol %20
path.replace(/(\s+)/g, '%20')
return fixedPath
}

function getLegendaryBin() {
Expand All @@ -55,6 +58,9 @@ function getLegendaryBin() {
isWindows ? 'legendary.exe' : 'legendary'
)
)}`
if (bin.includes(' ')) {
return `"${bin}"`
}

logInfo(`Location: ${bin}`, LogPrefix.Legendary)
return fixPathWithSpaces(bin)
Expand All @@ -71,6 +77,9 @@ function getGOGdlBin() {
isWindows ? 'gogdl.exe' : 'gogdl'
)
)
if (bin.includes(' ')) {
return `"${bin}"`
}
logInfo(`Location: ${bin}`, LogPrefix.Gog)
return fixPathWithSpaces(bin)
}
Expand Down
13 changes: 12 additions & 1 deletion electron/legendary/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { execAsync, isEpicServiceOffline, isOnline } from '../utils'
import {
fallBackImage,
installed,
isWindows,
legendaryBin,
legendaryConfigPath,
libraryPath
Expand All @@ -28,6 +29,7 @@ import { logError, logInfo, LogPrefix, logWarning } from '../logger/logger'
import { spawn } from 'child_process'
import Store from 'electron-store'
import { GlobalConfig } from '../config'
import path from 'path'

const libraryStore = new Store({
cwd: 'lib-cache',
Expand Down Expand Up @@ -96,9 +98,16 @@ class LegendaryLibrary {

return new Promise((res, rej) => {
const getUeAssets = showUnrealMarket ? '--include-ue' : ''
const child = spawn(legendaryBin, ['list', getUeAssets], { shell: true })
const legendaryPath = path.dirname(legendaryBin).replaceAll('"', '')
process.chdir(legendaryPath)
const child = spawn(
isWindows ? 'legendary.exe' : 'legendary',
['list', getUeAssets],
{ shell: isWindows }
)
child.stderr.on('data', (data) => {
if (`${data}`.includes('ERROR')) {
console.log(`${data}`)
logError(`${data}`.trim(), LogPrefix.Legendary)
} else {
logInfo(`${data}`.trim(), LogPrefix.Legendary)
Expand All @@ -112,6 +121,8 @@ class LegendaryLibrary {
this.loadAll()
})
.catch((err) => {
console.log(`${err}`)

logError(err, LogPrefix.Legendary)
})
}
Expand Down
8 changes: 6 additions & 2 deletions electron/legendary/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'graceful-fs'

import { UserInfo } from '../types'
import { clearCache, execAsync } from '../utils'
import { legendaryBin, userInfo } from '../constants'
import { isWindows, legendaryBin, userInfo } from '../constants'
import { logError, logInfo, LogPrefix } from '../logger/logger'
import { spawn } from 'child_process'
import { userInfo as user } from 'os'
Expand All @@ -18,7 +18,11 @@ export class LegendaryUser {

const command = `auth --sid ${sid}`.split(' ')
return new Promise((res) => {
const child = spawn(legendaryBin, command, { shell: true })
const legendaryPath = path.dirname(legendaryBin).replaceAll('"', '')
process.chdir(legendaryPath)
const child = spawn(isWindows ? 'legendary.exe' : 'legendary', command, {
shell: isWindows
})
child.stderr.on('data', (data) => {
if (`${data}`.includes('ERROR')) {
logError(`${data}`, LogPrefix.Legendary)
Expand Down