Rall3n / galaxy-integration-amazon

GOG Galaxy 2.0 integration for the Amazon Games Launcher
GNU General Public License v3.0
303 stars 16 forks source link

Installed games don't show as "installed" #10

Open doughsay opened 3 years ago

doughsay commented 3 years ago

Additionally, clicking the "install" button from inside GoG Galaxy just launches the game. So, it does "work", it just doesn't mark the game as installed.

doughsay commented 3 years ago

I disconnected the plugin, installed the game through amazon games client, then re-connected the plugin and it recognized the game I installed.

Rall3n commented 3 years ago

@doughsay Would you mind uploading your plugin log files for further analysis?

They should be located at C:\ProgramData\GOG.com\Galaxy\logs.

doughsay commented 3 years ago

Here's today's log. I just booted up and the two games I have installed in Amazon Games no longer show as installed in GoG Galaxy.

plugin-amazon-c2cd2e29-8b02-35a9-86fc-3faf90255857.log

I have "Cultist Simulator" and "Along the Edge" installed, and they were showing as installed yesterday, but they now no longer are.

Here are the only other two logs I have:

plugin-amazon-c2cd2e29-8b02-35a9-86fc-3faf90255857-1.log plugin-amazon-c2cd2e29-8b02-35a9-86fc-3faf90255857-2.log

Rall3n commented 3 years ago

As I thought. This is an issue I already observed happening over the week.

For some unknown reason Galaxy is not calling the necessary functions for importing local games (also updating the owned games) after plugin start until much later (I observed a minimum of an hour).

I don´t know why this is happening, as there is no indication of an error in any of the Galaxy logs. It will resume functionality on some specific edge cases (for example restarting the plugin).

rodrigovda commented 3 years ago

I have the same issue, I just Installed the plugin, it fetched my owned games correctly but it doesn't show the installed ones. This is the only log I got for this plugin: plugin-amazon-c2cd2e29-8b02-35a9-86fc-3faf90255857.log

My currently installed games are "Ape Out" and "Enter the Gungeon"

RodrigoTomeES commented 3 years ago

I have the same issue, but I think the problem is that the plugin doesn't sync with Amazon app after the first sync. I believe this because it has also not synced the new February free games that I purchased today.

Edit: After one day, the plugin shows the new games

mbanczerowski commented 3 years ago

GOG dev here. Issue confirmed and passed to investigation. As a workaround I can propose sending update_local_game_status shortly after handshake_complete

Rall3n commented 3 years ago

I have released a new version (v0.3.0) with a workaround. But I will keep this issue open until the main issue has been fixed.

mbanczerowski commented 3 years ago

Hi @Rall3n, the problem does not occur already. Could you confirm?

Rall3n commented 3 years ago

@mbanczerowski Unfortunately I can not confirm. Latest log still shows no call of tasks import_local_games and import_owned_games.

mbanczerowski commented 3 years ago

Thanks for checking. Looks like only some plugins are affected, I'm passing that back to Galaxy issue.

mbanczerowski commented 3 years ago

Hi @Rall3n, the Galaxy version 2.0.37 has included some fixes for that matter. Could you confirm if it works this time?

Rall3n commented 3 years ago

@mbanczerowski I saw the changelog of the latest beta version. I could observe that import_local_games is now called. Unfortunately it runs before authentication has finished, but that is something I have already dealt with.

Only thing not working now is import_owned_games, but I think the the topic of this issue has been resolved.

mbanczerowski commented 3 years ago

@Rall3n Reproduced and passed to Galaxy team.

Is far as I know both get_owned_games and get_local_games (again) should be called after authorization. Is the issue with

Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\GOG.com\Galaxy\plugins\installed\amazon_c2cd2e29-8b02-35a9-86fc-3faf90255857\plugin.py", line 80, in _get_local_games
    for row in self._local_games_db.select('DbSet', rows=['Id', 'Installed']) if row['Installed']

is this log error related to asking for local games before authentication? If so, consider raising galaxy.api.errors.AuthenticationRequired. It is currently not handle in Galaxy, but at least we'll gather some stats for future. Could you also explain why authentication is needed to access the db? It may be relevant for Galaxy future release as we considered separating local and owned games at all.

I is up to you to leave the current issue or resolve it and create another one. In the second case please leave a link so we can follow up. Thanks!

Rall3n commented 3 years ago

@mbanczerowski

Is the issue with [...] is this log error related to asking for local games before authentication?

Yes. That is the error that is being thrown when trying to access the database before authentication has finished.

Could you also explain why authentication is needed to access the db? It may be relevant for Galaxy future release as we considered separating local and owned games at all.

As you may know, this plugin requires the Amazon Games app to be installed and authenticated in order to access relevant game data as the plugin does not use API endpoints in its current state. This includes both owned games and local games, both of which have their own SQLite database file.

The authentication process ensures that the app is installed and that both databases are present. If the application is removed between quitting and starting Galaxy, get_local_games would throw an error when trying to access the database, as the variables are not set.

I could hardcode the paths to both databases to ensure task completion without the need for authentication using pathlib and Windows environment variables, but I would like to avoid hardcoding a complete path.

If so, consider raising galaxy.api.errors.AuthenticationRequired. It is currently not handle in Galaxy, but at least we'll gather some stats for future.

I will consider throwing an exception with this class.

I is up to you to leave the current issue or resolve it and create another one. In the second case please leave a link so we can follow up.

I will keep this issue open for now, but will create another issue regarding the same problem with get_owned_games with a reference to this issue and a ping at you.

mbanczerowski commented 3 years ago

@Rall3n thanks for explanation.

The authentication process ensures that the app is installed and that both databases are present. If the application is removed between quitting and starting Galaxy, get_local_games would throw an error when trying to access the database, as the variables are not set.

I've just checked your code and looks like no externally-dependent logic is performed on _on_auth. For the first time AmazonGames launcher installation state is checked here https://github.com/Rall3n/galaxy-integration-amazon/blob/master/src/client.py#L16 - on the plugin construction time. So I've just moved AmazonGamesPlugin._init_db to the plugin constructor and everything works (at least when Amazon client is installed). But it looks more logically correct to call AmazonGamesPlugin._init_db for the first time whenever the Amazon client installation is detected (which is actually already tracked periodically on a tick method). For example:

def tick(self):
    self._client.update_install_location()
    if self._client.is_installed:

        if not self._owned_games_db:
            self._owned_games_db = ...
        if not self._local_games_db:
            self._local_games_db = ...

        # ...

Then returning empty list from get_local_games always when the client is not installed seems to be safe.