RZetko / galaxy-integration-ffxiv

Final Fantasy XIV integration for GOG Galaxy 2
MIT License
10 stars 6 forks source link

Exception on owned games if game not fully installed #5

Closed FriendsOfGalaxy closed 4 years ago

FriendsOfGalaxy commented 5 years ago

Hello,

If a user downloads final fantasy installer but didn't finish downloading the game itself then plugin will recognize it as installed (a registry entry is created i guess) but it will throw an exception on owned games because the folder structure is not as expected

2019-11-25 12:46:43,343 - root - INFO - Handling request: id=8, method=import_local_games, params={}
2019-11-25 12:46:43,381 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "8", "result": {"local_games": [{"game_id": "final_fantasy_xiv_shadowbringers", "local_game_state": 1}]}}
2019-11-25 12:46:43,381 - root - DEBUG - Received 68 bytes of data
2019-11-25 12:46:43,381 - root - INFO - Handling request: id=9, method=import_owned_games, params={}
2019-11-25 12:46:43,443 - root - ERROR - Unexpected exception raised in plugin handler
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\GOG.com\Galaxy\plugins\installed\ff\modules\galaxy\api\jsonrpc.py", line 187, in handle
    result = await callback(*bound_args.args, **bound_args.kwargs)
  File "C:\Users\User\AppData\Local\GOG.com\Galaxy\plugins\installed\ff\modules\galaxy\api\plugin.py", line 152, in method
    result = await handler(*args, **kwargs)
  File "C:\Users\User\AppData\Local\GOG.com\Galaxy\plugins\installed\ff\plugin.py", line 115, in get_owned_games
    dlclist = [ item for item in os.listdir(dlc_folder) if os.path.isdir(os.path.join(dlc_folder, item)) ]
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'd:\\Program Files (x86)\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\'
2019-11-25 12:46:43,445 - root - DEBUG - Sending data: {"jsonrpc": "2.0", "id": "9", "error": {"code": 0, "message": "Unknown error", "data": "[WinError 3] The system cannot find the path specified: 'd:\\\\Program Files (x86)\\\\SquareEnix\\\\FINAL FANTASY XIV - A Realm Reborn\\\\game\\\\sqpack\\\\'"}}
2019-11-25 12:46:43,446 - root - DEBUG - Received 65 bytes of data
2019-11-25 12:46:43,446 - root - INFO - Handling request: id=10, method=import_friends, params={}

image

Tbh i think that owned game status should not be based on local files and in the case of a plugin for a single game its fine to simply report it as owned from the get go (without dlcs - from what i see galaxy doesnt react to dlc information in any way right now).

If you can't find the dlc ownership through endpoint then its completely reasonable to do self.add_game() for the same id and title with additional dlc information once you find them locally (since its an additional info).

Lastly it would be best to check if path exists whenever you do such operations.

RZetko commented 4 years ago

I'm really sorry, I completely missed both #13 and #11 PRs. I merged them right away and also updated all dependencies to latest versions in new release 1.2.2. Thank you very much for your help.