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
Refactor Legendary/GOGDL handling #1092
Refactor Legendary/GOGDL handling #1092
Conversation
f1713bc
to
43f7d3a
Compare
Someone please add this to Project Beans. :P Thanks for this PR, I wanted to get this done for a while but didn't have the time. |
There's an issue with Linux-native GOG games not installing properly right now. I'm working on it |
It seems like everything is working now, the only issue is that installing GOG games doesn't get registered properly so you have to press the "Refresh Library" button once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested here for a bit and could not find any bug or issue so looks good.
I believe testing on other platforms and on Flatpak would be good as well. I will try to test on a Mac tomorrow.
Also, @imLinguin would be nice if you could take a look at it as well, especially the GOG part.
But pretty good job with the refactor.
The code is cleaner and more efficient now. Also, more easy to scalate ⚔️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at GOG changes. Looks good to me
installedGamesStore.set('installed', array) | ||
GOGLibrary.get().refreshInstalled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About bug you mentioned. This might be a race condition we are looking for, since refreshInstalled reads from the same config. Maybe a function to update installed games directly in memory (instead of reading from the same file again) will solve the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could do it like this from now on. Perhaps on another PR:
After refreshing the library on the backend, we send an event to the frontend to refresh the state.
This way we could solve the racing conditions.
This changes every legendary/gogdl-related function to call runLegendaryCommand/runGogdlCommand. With that, it unifies the ~3 different approaches used before into one (hopefully) easy-to-understand function. This has the added benefit that if this function breaks, it'll break everywhere. This should prevent a scenario like in the past few days from happening, as either everything or nothing works.
There were a few unnecessary newlines here that I remove with .trim()
Not sure why this was done like this, seems to still work fine now
This is kinda hacky, but it stops weird things from happening when starting a download, quitting heroic, and then starting it again
This changes just about all implementations of ExecResult to use the new error property
45e2985
to
027290f
Compare
Tested these changes on a Mac and looks good as well. |
|
||
if (logFile) { | ||
child.stdout.on('data', (data: Buffer) => { | ||
appendFileSync(logFile, data.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos for all the changes, but maybe you shouldn't use sync method. Also, new file handle is created for each chunk. This could lead to blocking of app.
I suggest opening a file once and appending to it.
I suggest creating writeable stream from file and piping output directly to that stream
It would be also nice to use node's readline module. This would enable further changes to fix the atrocity that is the requestGameProgress
handler: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/main/electron/main.ts#L1100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this definitely needs improvement, but I'm afraid that I don't know enough about the language yet to make these changes + they don't really fit into this PR. I'd say we merge this for now & then we can look into improving it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it can be added later.
This PR unifies every instance of running/invoking Legendary/GOGDL to use one function each (
runLegendaryCommand
/runGogdlCommand
).It improves a few things in the process:process.chdir()
is no longer necessary%PATH%
/$PATH
is no longer necessarycwd
option ofspawn
)ExecResult
now has an optionalfullCommand
argument to indicate the exact command that was ranUse the following Checklist if you have changed something on the Backend or Frontend:
Note: Testing was, as usual, done on Linux and Windows. I don't have a Mac, if anyone could test on there, that would be great