Repository: lutris/lutris

Issue:
Installing an update from GOG creates a blank game
### Bug description

When you use the "install update" command, once the install completes Lutris will create a new blank PGA entry. It is not considered installed and has no data, but has a new ID.

### How to Reproduce

I repro this with a GOG game that does not have a proper update- Lutris will reinstall the game in that case. I am using "Project Warlock". The bug occurs even though this game is already up to date.

Go into Lutris and use the "Install Update" command on the game. Install the 'update' normally- we're just reinstalling which is fine.

Now, show games that are not installed. Look around in your Games section; you will see a blank icon or banner with no name. That is the bug. That should not be created.

The installer save code is not providing a game id, and this blank entry is the result of trying to resave this- apparenly just to trigger the game-updated signal.

### Expected behavior

The blank banner or icon should not be created; no new game is wanted here.

### Log output

```shell
2022-03-06 08:56:58,087: Starting Lutris 0.5.10
2022-03-06 08:56:58,105: No folder at /home/danj/.local/share/lutris/runners/retroarch/
2022-03-06 08:56:58,123: Using NVIDIA drivers 510.54 for x86_64
2022-03-06 08:56:58,123: GPU: Unknown
2022-03-06 08:56:58,124: GPU: 10DE:2503 196E:1377 (nvidia drivers)
2022-03-06 08:56:58,164: Startup complete
2022-03-06 08:57:02,008: Getting game details for 1459073823
2022-03-06 08:57:03,928: Getting runner information for wine
2022-03-06 08:57:04,146: Getting game details for 1459073823
2022-03-06 08:57:04,180: Getting game details for 1459073823
2022-03-06 08:57:05,759: Getting files for gogpatch_1058
2022-03-06 08:57:05,759: Adding selected extras to downloads
2022-03-06 08:57:05,759: Getting game details for 1459073823
2022-03-06 08:57:05,799: Getting download info for https://api.gog.com/products/1459073823/downlink/patch/en1patch0
2022-03-06 08:57:14,620: Download completed
2022-03-06 08:57:14,620: All files available
2022-03-06 08:57:14,620: All files are available, continuing install
Started initial process 39952 from /home/danj/.local/share/lutris/runners/wine/lutris-fshack-7.1-x86_64/bin/wine /home/danj/.cache/lutris/installer/project-warlock/gog/setup_project_warlock_1.0.5.8_(32bit)_(54097).exe
Start monitoring process.
fsync: up and running.
Monitored process exited.
Initial process has exited (return code: 0)
Exit with return code 0
2022-03-06 08:57:43,082: This is an extension to project-warlock-gog-w-dxvk, not creating a new game entry
2022-03-06 08:57:43,312: Saving Game (no name) without a configuration
2022-03-06 08:57:43,313: Game has no runner, can't set platform
2022-03-06 08:57:58,951: Shutting down Lutris
```


### System Information

```shell
[System]
OS:              Pop!_OS 21.10 impish
Arch:            x86_64
Kernel:          5.16.11-76051611-generic
Desktop:         GNOME
Display Server:  x11

[CPU]
Vendor:          AuthenticAMD
Model:           AMD Ryzen 7 5800X 8-Core Processor
Physical cores:  8
Logical cores:   16

[Memory]
RAM:             31.4 GB
Swap:            0.0 GB

[Graphics]
Vendor:          NVIDIA Corporation
OpenGL Renderer: NVIDIA GeForce RTX 3060/PCIe/SSE2
OpenGL Version:  4.6.0 NVIDIA 510.54
OpenGL Core:     4.6.0 NVIDIA 510.54
OpenGL ES:       OpenGL ES 3.2 NVIDIA 510.54
Vulkan:          Supported
```


### Media (optional)

![Screenshot from 2022-03-06 09-03-31](https://user-images.githubusercontent.com/6507403/156926621-784d22b4-7282-4da6-9871-0dc53b3aebb0.png)


### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:

Resolving patch:
diff --git a/lutris/gui/installerwindow.py b/lutris/gui/installerwindow.py
--- a/lutris/gui/installerwindow.py
+++ b/lutris/gui/installerwindow.py
@@ -465,9 +465,11 @@ def on_install_finished(self, game_id):
         if self.config.get("create_menu_shortcut"):
             self.create_shortcut()
 
-        # Save game to trigger a game-updated signal
-        game = Game(game_id)
-        game.save()
+        # Save game to trigger a game-updated signal,
+        # but take care not to create a blank game
+        if game_id:
+            game = Game(game_id)
+            game.save()
 
         self.install_in_progress = False
 
@@ -477,7 +479,7 @@ def on_install_finished(self, game_id):
         self.cancel_button.hide()
         self.continue_button.hide()
         self.install_button.hide()
-        if game.id:
+        if game and game.id:
             self.play_button.show()
 
         self.close_button.grab_focus()
diff --git a/lutris/installer/installer.py b/lutris/installer/installer.py
--- a/lutris/installer/installer.py
+++ b/lutris/installer/installer.py
@@ -79,7 +79,7 @@ def get_game_id(self):
         # If the game is in the library and uninstalled, the first installation
         # updates it
         existing_game = get_game_by_field(self.game_slug, "slug")
-        if existing_game and not existing_game["installed"]:
+        if existing_game and (self.extends or not existing_game["installed"]):
             return existing_game["id"]
 
     @property
@@ -241,7 +241,7 @@ def save(self):
                 "This is an extension to %s, not creating a new game entry",
                 self.extends,
             )
-            return
+            return self.game_id
 
         if self.is_gog:
             gog_config = get_gog_config_from_path(self.interpreter.target_path)


Test patch: