We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Importing of Steam games that are already in the library (uninstalled) does not make them appear installed
How to reproduce:
1. Add a game to your game library on Lutris.Net
2. Relaunch Lutris to let it fetch the new data and add the game to the library
3. Have that game installed locally through Steam
4. Import the game through "Import Games" menu

Expected behavior: the game now appears in the library as installed and is ready to be launched
Observed Behavior: nothing happens, the game remains uninstalled in the library until you manually run the installer it

A lot of users get confused by this because they think the Importing process failed as nothing happens after the importing process.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lutris/services/steam.py`
Content:
```
1 """Steam service"""
2 import os
3 import re
4 
5 from lutris import pga
6 from lutris.config import make_game_config_id, LutrisConfig
7 from lutris.util.steam.appmanifest import AppManifest, get_appmanifests
8 from lutris.util.steam.config import get_steamapps_paths
9 from lutris.services.service_game import ServiceGame
10 
11 NAME = "Steam"
12 ICON = "steam"
13 ONLINE = False
14 
15 
16 class SteamGame(ServiceGame):
17     """ServiceGame for Steam games"""
18     store = "steam"
19     installer_slug = "steam"
20     excluded_appids = [
21         "228980",  # Steamworks Common Redistributables
22     ]
23 
24     @classmethod
25     def new_from_steam_game(cls, appmanifest, game_id=None):
26         """Return a Steam game instance from an AppManifest"""
27         steam_game = SteamGame()
28         steam_game.appid = str(appmanifest.steamid)
29         steam_game.game_id = game_id
30         steam_game.name = appmanifest.name
31         steam_game.slug = appmanifest.slug
32         steam_game.runner = appmanifest.get_runner_name()
33         return steam_game
34 
35     @classmethod
36     def new_from_lutris_id(cls, game_id):
37         steam_game = SteamGame()
38         steam_game.game_id = game_id
39         return steam_game
40 
41     @property
42     def config_id(self):
43         return make_game_config_id(self.slug)
44 
45     @classmethod
46     def is_importable(cls, appmanifest):
47         """Return whether a Steam game should be imported"""
48         if not appmanifest.is_installed():
49             return False
50         if appmanifest.steamid in cls.excluded_appids:
51             return False
52         if re.match(r"^Proton \d*", appmanifest.name):
53             return False
54         return True
55 
56     def install(self, updated_info=None):
57         """Add an installed game to the library
58 
59         Params:
60             updated_info (dict): Optional dictonary containing existing data not to overwrite
61         """
62         if updated_info:
63             name = updated_info["name"]
64             slug = updated_info["slug"]
65         else:
66             name = self.name
67             slug = self.slug
68         self.game_id = pga.add_or_update(
69             id=self.game_id,
70             name=name,
71             runner=self.runner,
72             slug=slug,
73             steamid=int(self.appid),
74             installed=1,
75             configpath=self.config_id,
76             installer_slug=self.installer_slug,
77         )
78         self.create_config()
79         return self.game_id
80 
81     def create_config(self):
82         """Create the game configuration for a Steam game"""
83         game_config = LutrisConfig(runner_slug=self.runner, game_config_id=self.config_id)
84         game_config.raw_game_config.update({"appid": self.appid})
85         game_config.save()
86 
87 
88 class SteamSyncer:
89     platform = "linux"
90 
91     def __init__(self):
92         self._lutris_games = None
93         self._lutris_steamids = None
94 
95     @property
96     def runner(self):
97         return "steam" if self.platform == "linux" else "winesteam"
98 
99     @property
100     def lutris_games(self):
101         if not self._lutris_games:
102             self._lutris_games = pga.get_games_where(
103                 steamid__isnull=False,
104                 steamid__not=""
105             )
106         return self._lutris_games
107 
108     @property
109     def lutris_steamids(self):
110         if not self._lutris_steamids:
111             self._lutris_steamids = {str(game["steamid"]) for game in self.lutris_games}
112         return self._lutris_steamids
113 
114     def load(self, force_reload=False):
115         """Return importable Steam games"""
116         games = []
117         steamapps_paths = get_steamapps_paths()
118         for steamapps_path in steamapps_paths[self.platform]:
119             for appmanifest_file in get_appmanifests(steamapps_path):
120                 app_manifest = AppManifest(os.path.join(steamapps_path, appmanifest_file))
121                 if SteamGame.is_importable(app_manifest):
122                     games.append(SteamGame.new_from_steam_game(app_manifest))
123         return games
124 
125     def get_pga_game(self, game):
126         """Return a PGA game if one is found"""
127         for pga_game in self.lutris_games:
128             if (
129                     str(pga_game["steamid"]) == game.appid
130                     and pga_game["runner"] == self.runner
131                     and not pga_game["installed"]
132             ):
133                 return pga_game
134 
135     def sync(self, games, full=False):
136         """Syncs Steam games to Lutris"""
137         available_ids = set()  # Set of Steam appids seen while browsing AppManifests
138         added_games = []
139         for game in games:
140             steamid = game.appid
141             available_ids.add(steamid)
142             pga_game = self.get_pga_game(game)
143 
144             if pga_game:
145                 if steamid in self.lutris_steamids and pga_game["installed"] != 1 and pga_game["installed"]:
146                     added_games.append(game.install())
147 
148             if steamid not in self.lutris_steamids:
149                 added_games.append(game.install())
150             else:
151                 if pga_game:
152                     added_games.append(game.install(pga_game))
153 
154         if not full:
155             return added_games
156 
157         removed_games = []
158         unavailable_ids = self.lutris_steamids.difference(available_ids)
159         for steamid in unavailable_ids:
160             for pga_game in self.lutris_games:
161                 if (
162                         str(pga_game["steamid"]) == steamid
163                         and pga_game["installed"]
164                         and pga_game["runner"] == self.runner
165                 ):
166                     game = SteamGame.new_from_lutris_id(pga_game["id"])
167                     game.uninstall()
168                     removed_games.append(pga_game["id"])
169         return (added_games, removed_games)
170 
171 
172 SYNCER = SteamSyncer
173
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lutris/services/steam.py b/lutris/services/steam.py
--- a/lutris/services/steam.py
+++ b/lutris/services/steam.py
@@ -127,7 +127,7 @@
         for pga_game in self.lutris_games:
             if (
                     str(pga_game["steamid"]) == game.appid
-                    and pga_game["runner"] == self.runner
+                    and (pga_game["runner"] == self.runner or not pga_game["runner"])
                     and not pga_game["installed"]
             ):
                 return pga_game

{"golden_diff": "diff --git a/lutris/services/steam.py b/lutris/services/steam.py\n--- a/lutris/services/steam.py\n+++ b/lutris/services/steam.py\n@@ -127,7 +127,7 @@\n         for pga_game in self.lutris_games:\n             if (\n                     str(pga_game[\"steamid\"]) == game.appid\n-                    and pga_game[\"runner\"] == self.runner\n+                    and (pga_game[\"runner\"] == self.runner or not pga_game[\"runner\"])\n                     and not pga_game[\"installed\"]\n             ):\n                 return pga_game\n", "issue": "Importing of Steam games that are already in the library (uninstalled) does not make them appear installed\nHow to reproduce:\r\n1. Add a game to your game library on Lutris.Net\r\n2. Relaunch Lutris to let it fetch the new data and add the game to the library\r\n3. Have that game installed locally through Steam\r\n4. Import the game through \"Import Games\" menu\r\n\r\nExpected behavior: the game now appears in the library as installed and is ready to be launched\r\nObserved Behavior: nothing happens, the game remains uninstalled in the library until you manually run the installer it\r\n\r\nA lot of users get confused by this because they think the Importing process failed as nothing happens after the importing process.\n", "before_files": [{"content": "\"\"\"Steam service\"\"\"\nimport os\nimport re\n\nfrom lutris import pga\nfrom lutris.config import make_game_config_id, LutrisConfig\nfrom lutris.util.steam.appmanifest import AppManifest, get_appmanifests\nfrom lutris.util.steam.config import get_steamapps_paths\nfrom lutris.services.service_game import ServiceGame\n\nNAME = \"Steam\"\nICON = \"steam\"\nONLINE = False\n\n\nclass SteamGame(ServiceGame):\n    \"\"\"ServiceGame for Steam games\"\"\"\n    store = \"steam\"\n    installer_slug = \"steam\"\n    excluded_appids = [\n        \"228980\",  # Steamworks Common Redistributables\n    ]\n\n    @classmethod\n    def new_from_steam_game(cls, appmanifest, game_id=None):\n        \"\"\"Return a Steam game instance from an AppManifest\"\"\"\n        steam_game = SteamGame()\n        steam_game.appid = str(appmanifest.steamid)\n        steam_game.game_id = game_id\n        steam_game.name = appmanifest.name\n        steam_game.slug = appmanifest.slug\n        steam_game.runner = appmanifest.get_runner_name()\n        return steam_game\n\n    @classmethod\n    def new_from_lutris_id(cls, game_id):\n        steam_game = SteamGame()\n        steam_game.game_id = game_id\n        return steam_game\n\n    @property\n    def config_id(self):\n        return make_game_config_id(self.slug)\n\n    @classmethod\n    def is_importable(cls, appmanifest):\n        \"\"\"Return whether a Steam game should be imported\"\"\"\n        if not appmanifest.is_installed():\n            return False\n        if appmanifest.steamid in cls.excluded_appids:\n            return False\n        if re.match(r\"^Proton \\d*\", appmanifest.name):\n            return False\n        return True\n\n    def install(self, updated_info=None):\n        \"\"\"Add an installed game to the library\n\n        Params:\n            updated_info (dict): Optional dictonary containing existing data not to overwrite\n        \"\"\"\n        if updated_info:\n            name = updated_info[\"name\"]\n            slug = updated_info[\"slug\"]\n        else:\n            name = self.name\n            slug = self.slug\n        self.game_id = pga.add_or_update(\n            id=self.game_id,\n            name=name,\n            runner=self.runner,\n            slug=slug,\n            steamid=int(self.appid),\n            installed=1,\n            configpath=self.config_id,\n            installer_slug=self.installer_slug,\n        )\n        self.create_config()\n        return self.game_id\n\n    def create_config(self):\n        \"\"\"Create the game configuration for a Steam game\"\"\"\n        game_config = LutrisConfig(runner_slug=self.runner, game_config_id=self.config_id)\n        game_config.raw_game_config.update({\"appid\": self.appid})\n        game_config.save()\n\n\nclass SteamSyncer:\n    platform = \"linux\"\n\n    def __init__(self):\n        self._lutris_games = None\n        self._lutris_steamids = None\n\n    @property\n    def runner(self):\n        return \"steam\" if self.platform == \"linux\" else \"winesteam\"\n\n    @property\n    def lutris_games(self):\n        if not self._lutris_games:\n            self._lutris_games = pga.get_games_where(\n                steamid__isnull=False,\n                steamid__not=\"\"\n            )\n        return self._lutris_games\n\n    @property\n    def lutris_steamids(self):\n        if not self._lutris_steamids:\n            self._lutris_steamids = {str(game[\"steamid\"]) for game in self.lutris_games}\n        return self._lutris_steamids\n\n    def load(self, force_reload=False):\n        \"\"\"Return importable Steam games\"\"\"\n        games = []\n        steamapps_paths = get_steamapps_paths()\n        for steamapps_path in steamapps_paths[self.platform]:\n            for appmanifest_file in get_appmanifests(steamapps_path):\n                app_manifest = AppManifest(os.path.join(steamapps_path, appmanifest_file))\n                if SteamGame.is_importable(app_manifest):\n                    games.append(SteamGame.new_from_steam_game(app_manifest))\n        return games\n\n    def get_pga_game(self, game):\n        \"\"\"Return a PGA game if one is found\"\"\"\n        for pga_game in self.lutris_games:\n            if (\n                    str(pga_game[\"steamid\"]) == game.appid\n                    and pga_game[\"runner\"] == self.runner\n                    and not pga_game[\"installed\"]\n            ):\n                return pga_game\n\n    def sync(self, games, full=False):\n        \"\"\"Syncs Steam games to Lutris\"\"\"\n        available_ids = set()  # Set of Steam appids seen while browsing AppManifests\n        added_games = []\n        for game in games:\n            steamid = game.appid\n            available_ids.add(steamid)\n            pga_game = self.get_pga_game(game)\n\n            if pga_game:\n                if steamid in self.lutris_steamids and pga_game[\"installed\"] != 1 and pga_game[\"installed\"]:\n                    added_games.append(game.install())\n\n            if steamid not in self.lutris_steamids:\n                added_games.append(game.install())\n            else:\n                if pga_game:\n                    added_games.append(game.install(pga_game))\n\n        if not full:\n            return added_games\n\n        removed_games = []\n        unavailable_ids = self.lutris_steamids.difference(available_ids)\n        for steamid in unavailable_ids:\n            for pga_game in self.lutris_games:\n                if (\n                        str(pga_game[\"steamid\"]) == steamid\n                        and pga_game[\"installed\"]\n                        and pga_game[\"runner\"] == self.runner\n                ):\n                    game = SteamGame.new_from_lutris_id(pga_game[\"id\"])\n                    game.uninstall()\n                    removed_games.append(pga_game[\"id\"])\n        return (added_games, removed_games)\n\n\nSYNCER = SteamSyncer\n", "path": "lutris/services/steam.py"}], "after_files": [{"content": "\"\"\"Steam service\"\"\"\nimport os\nimport re\n\nfrom lutris import pga\nfrom lutris.config import make_game_config_id, LutrisConfig\nfrom lutris.util.steam.appmanifest import AppManifest, get_appmanifests\nfrom lutris.util.steam.config import get_steamapps_paths\nfrom lutris.services.service_game import ServiceGame\n\nNAME = \"Steam\"\nICON = \"steam\"\nONLINE = False\n\n\nclass SteamGame(ServiceGame):\n    \"\"\"ServiceGame for Steam games\"\"\"\n    store = \"steam\"\n    installer_slug = \"steam\"\n    excluded_appids = [\n        \"228980\",  # Steamworks Common Redistributables\n    ]\n\n    @classmethod\n    def new_from_steam_game(cls, appmanifest, game_id=None):\n        \"\"\"Return a Steam game instance from an AppManifest\"\"\"\n        steam_game = SteamGame()\n        steam_game.appid = str(appmanifest.steamid)\n        steam_game.game_id = game_id\n        steam_game.name = appmanifest.name\n        steam_game.slug = appmanifest.slug\n        steam_game.runner = appmanifest.get_runner_name()\n        return steam_game\n\n    @classmethod\n    def new_from_lutris_id(cls, game_id):\n        steam_game = SteamGame()\n        steam_game.game_id = game_id\n        return steam_game\n\n    @property\n    def config_id(self):\n        return make_game_config_id(self.slug)\n\n    @classmethod\n    def is_importable(cls, appmanifest):\n        \"\"\"Return whether a Steam game should be imported\"\"\"\n        if not appmanifest.is_installed():\n            return False\n        if appmanifest.steamid in cls.excluded_appids:\n            return False\n        if re.match(r\"^Proton \\d*\", appmanifest.name):\n            return False\n        return True\n\n    def install(self, updated_info=None):\n        \"\"\"Add an installed game to the library\n\n        Params:\n            updated_info (dict): Optional dictonary containing existing data not to overwrite\n        \"\"\"\n        if updated_info:\n            name = updated_info[\"name\"]\n            slug = updated_info[\"slug\"]\n        else:\n            name = self.name\n            slug = self.slug\n        self.game_id = pga.add_or_update(\n            id=self.game_id,\n            name=name,\n            runner=self.runner,\n            slug=slug,\n            steamid=int(self.appid),\n            installed=1,\n            configpath=self.config_id,\n            installer_slug=self.installer_slug,\n        )\n        self.create_config()\n        return self.game_id\n\n    def create_config(self):\n        \"\"\"Create the game configuration for a Steam game\"\"\"\n        game_config = LutrisConfig(runner_slug=self.runner, game_config_id=self.config_id)\n        game_config.raw_game_config.update({\"appid\": self.appid})\n        game_config.save()\n\n\nclass SteamSyncer:\n    platform = \"linux\"\n\n    def __init__(self):\n        self._lutris_games = None\n        self._lutris_steamids = None\n\n    @property\n    def runner(self):\n        return \"steam\" if self.platform == \"linux\" else \"winesteam\"\n\n    @property\n    def lutris_games(self):\n        if not self._lutris_games:\n            self._lutris_games = pga.get_games_where(\n                steamid__isnull=False,\n                steamid__not=\"\"\n            )\n        return self._lutris_games\n\n    @property\n    def lutris_steamids(self):\n        if not self._lutris_steamids:\n            self._lutris_steamids = {str(game[\"steamid\"]) for game in self.lutris_games}\n        return self._lutris_steamids\n\n    def load(self, force_reload=False):\n        \"\"\"Return importable Steam games\"\"\"\n        games = []\n        steamapps_paths = get_steamapps_paths()\n        for steamapps_path in steamapps_paths[self.platform]:\n            for appmanifest_file in get_appmanifests(steamapps_path):\n                app_manifest = AppManifest(os.path.join(steamapps_path, appmanifest_file))\n                if SteamGame.is_importable(app_manifest):\n                    games.append(SteamGame.new_from_steam_game(app_manifest))\n        return games\n\n    def get_pga_game(self, game):\n        \"\"\"Return a PGA game if one is found\"\"\"\n        for pga_game in self.lutris_games:\n            if (\n                    str(pga_game[\"steamid\"]) == game.appid\n                    and (pga_game[\"runner\"] == self.runner or not pga_game[\"runner\"])\n                    and not pga_game[\"installed\"]\n            ):\n                return pga_game\n\n    def sync(self, games, full=False):\n        \"\"\"Syncs Steam games to Lutris\"\"\"\n        available_ids = set()  # Set of Steam appids seen while browsing AppManifests\n        added_games = []\n        for game in games:\n            steamid = game.appid\n            available_ids.add(steamid)\n            pga_game = self.get_pga_game(game)\n\n            if pga_game:\n                if steamid in self.lutris_steamids and pga_game[\"installed\"] != 1 and pga_game[\"installed\"]:\n                    added_games.append(game.install())\n\n            if steamid not in self.lutris_steamids:\n                added_games.append(game.install())\n            else:\n                if pga_game:\n                    added_games.append(game.install(pga_game))\n\n        if not full:\n            return added_games\n\n        removed_games = []\n        unavailable_ids = self.lutris_steamids.difference(available_ids)\n        for steamid in unavailable_ids:\n            for pga_game in self.lutris_games:\n                if (\n                        str(pga_game[\"steamid\"]) == steamid\n                        and pga_game[\"installed\"]\n                        and pga_game[\"runner\"] == self.runner\n                ):\n                    game = SteamGame.new_from_lutris_id(pga_game[\"id\"])\n                    game.uninstall()\n                    removed_games.append(pga_game[\"id\"])\n        return (added_games, removed_games)\n\n\nSYNCER = SteamSyncer\n", "path": "lutris/services/steam.py"}]}