We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Lutris doesn't create coverart folder
### Bug description

After upgrading Lutris to v0.5.10-beta1 at every start a popup is shown with the text
`[Errno 2] No such file or directory: '/home/user/.cache/lutris/coverart'`

After clicking 'OK' Lutris starts normal
Restarting Lutris displays the popup again since the folder isn't created

Manually creating the 'coverart' folder works and Lutris starts fine

### How to Reproduce

Steps to reproduce the behavior:
1. Have v0.5.9.1 installed
2. Install v0.5.10-beta1
3. Open Lutris
4. See popup

### Expected behavior

Lutris shouldn't display a popup but create the missing folder

### Log output

```shell
INFO     2022-02-12 17:06:00,408 [startup.init_lutris:164]:Starting Lutris 0.5.10
WARNING  2022-02-12 17:06:00,427 [libretro.get_libretro_cores:48]:No cores found
DEBUG    2022-02-12 17:06:00,432 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR
INFO     2022-02-12 17:06:00,458 [startup.check_driver:65]:Running AMD Mesa driver 21.3.6 on AMD Radeon RX 5700 (NAVI10, DRM 3.44.0, 5.13.0-generic, LLVM 13.0.0) (0x731f)
INFO     2022-02-12 17:06:00,458 [startup.check_driver:77]:GPU: 1002:731F 148C:2398 (amdgpu drivers)
ERROR    2022-02-12 17:06:00,489 [jobs.target:36]:Error while completing task <bound method LutrisInitDialog.initialize of <dialogs.LutrisInitDialog object at 0x7fa950b9aac0 (lutris+gui+dialogs+LutrisInitDialog at 0x1aac2b0)>>: <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/home/user/.cache/lutris/coverart'
  File "/usr/lib/python3/dist-packages/lutris/util/jobs.py", line 34, in target
    result = self.function(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/lutris/gui/dialogs/__init__.py", line 195, in initialize
    init_lutris()
  File "/usr/lib/python3/dist-packages/lutris/startup.py", line 201, in update_runtime
    sync_media()
  File "/usr/lib/python3/dist-packages/lutris/services/lutris.py", line 159, in sync_media
    covers_available = {fn.split(".")[0] for fn in os.listdir(settings.COVERART_PATH)}
```

### 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.

--- 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/startup.py`
Content:
```
1 """Check to run at program start"""
2 import os
3 import sqlite3
4 import time
5 from gettext import gettext as _
6 
7 from lutris import runners, settings
8 from lutris.database.games import get_games
9 from lutris.database.schema import syncdb
10 from lutris.game import Game
11 from lutris.gui.dialogs import DontShowAgainDialog
12 from lutris.runners.json import load_json_runners
13 from lutris.runtime import RuntimeUpdater
14 from lutris.services import DEFAULT_SERVICES
15 from lutris.services.lutris import sync_media
16 from lutris.util import update_cache
17 from lutris.util.graphics import drivers, vkquery
18 from lutris.util.linux import LINUX_SYSTEM
19 from lutris.util.log import logger
20 from lutris.util.system import create_folder
21 from lutris.util.wine.d3d_extras import D3DExtrasManager
22 from lutris.util.wine.dgvoodoo2 import dgvoodoo2Manager
23 from lutris.util.wine.dxvk import DXVKManager
24 from lutris.util.wine.dxvk_nvapi import DXVKNVAPIManager
25 from lutris.util.wine.vkd3d import VKD3DManager
26 
27 
28 def init_dirs():
29     """Creates Lutris directories"""
30     directories = [
31         settings.CONFIG_DIR,
32         os.path.join(settings.CONFIG_DIR, "runners"),
33         os.path.join(settings.CONFIG_DIR, "games"),
34         settings.DATA_DIR,
35         os.path.join(settings.DATA_DIR, "covers"),
36         settings.ICON_PATH,
37         os.path.join(settings.CACHE_DIR, "banners"),
38         os.path.join(settings.DATA_DIR, "coverart"),
39         os.path.join(settings.DATA_DIR, "runners"),
40         os.path.join(settings.DATA_DIR, "lib"),
41         settings.RUNTIME_DIR,
42         settings.CACHE_DIR,
43         settings.SHADER_CACHE_DIR,
44         os.path.join(settings.CACHE_DIR, "installer"),
45         os.path.join(settings.CACHE_DIR, "tmp"),
46     ]
47     for directory in directories:
48         create_folder(directory)
49 
50 
51 def check_driver():
52     """Report on the currently running driver"""
53     driver_info = {}
54     if drivers.is_nvidia():
55         driver_info = drivers.get_nvidia_driver_info()
56         # pylint: disable=logging-format-interpolation
57         logger.info("Using {vendor} drivers {version} for {arch}".format(**driver_info["nvrm"]))
58         gpus = drivers.get_nvidia_gpu_ids()
59         for gpu_id in gpus:
60             gpu_info = drivers.get_nvidia_gpu_info(gpu_id)
61             logger.info("GPU: %s", gpu_info.get("Model"))
62     elif LINUX_SYSTEM.glxinfo:
63         # pylint: disable=no-member
64         if hasattr(LINUX_SYSTEM.glxinfo, "GLX_MESA_query_renderer"):
65             logger.info(
66                 "Running %s Mesa driver %s on %s",
67                 LINUX_SYSTEM.glxinfo.opengl_vendor,
68                 LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,
69                 LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device,
70             )
71     else:
72         logger.warning("glxinfo is not available on your system, unable to detect driver version")
73 
74     for card in drivers.get_gpus():
75         # pylint: disable=logging-format-interpolation
76         try:
77             logger.info("GPU: {PCI_ID} {PCI_SUBSYS_ID} ({DRIVER} drivers)".format(**drivers.get_gpu_info(card)))
78         except KeyError:
79             logger.error("Unable to get GPU information from '%s'", card)
80 
81     if drivers.is_outdated():
82         setting = "hide-outdated-nvidia-driver-warning"
83         if settings.read_setting(setting) != "True":
84             DontShowAgainDialog(
85                 setting,
86                 _("Your NVIDIA driver is outdated."),
87                 secondary_message=_(
88                     "You are currently running driver %s which does not "
89                     "fully support all features for Vulkan and DXVK games.\n"
90                     "Please upgrade your driver as described in our "
91                     "<a href='%s'>installation guide</a>"
92                 ) % (
93                     driver_info["nvrm"]["version"],
94                     settings.DRIVER_HOWTO_URL,
95                 )
96             )
97 
98 
99 def check_libs(all_components=False):
100     """Checks that required libraries are installed on the system"""
101     missing_libs = LINUX_SYSTEM.get_missing_libs()
102     if all_components:
103         components = LINUX_SYSTEM.requirements
104     else:
105         components = LINUX_SYSTEM.critical_requirements
106     missing_vulkan_libs = []
107     for req in components:
108         for index, arch in enumerate(LINUX_SYSTEM.runtime_architectures):
109             for lib in missing_libs[req][index]:
110                 if req == "VULKAN":
111                     missing_vulkan_libs.append(arch)
112                 logger.error("%s %s missing (needed by %s)", arch, lib, req.lower())
113 
114     if missing_vulkan_libs:
115         setting = "dismiss-missing-vulkan-library-warning"
116         if settings.read_setting(setting) != "True":
117             DontShowAgainDialog(
118                 setting,
119                 _("Missing vulkan libraries"),
120                 secondary_message=_(
121                     "Lutris was unable to detect Vulkan support for "
122                     "the %s architecture.\n"
123                     "This will prevent many games and programs from working.\n"
124                     "To install it, please use the following guide: "
125                     "<a href='%s'>Installing Graphics Drivers</a>"
126                 ) % (
127                     _(" and ").join(missing_vulkan_libs),
128                     settings.DRIVER_HOWTO_URL,
129                 )
130             )
131 
132 
133 def check_vulkan():
134     """Reports if Vulkan is enabled on the system"""
135     if not vkquery.is_vulkan_supported():
136         logger.warning("Vulkan is not available or your system isn't Vulkan capable")
137 
138 
139 def fill_missing_platforms():
140     """Sets the platform on games where it's missing.
141     This should never happen.
142     """
143     pga_games = get_games(filters={"installed": 1})
144     for pga_game in pga_games:
145         if pga_game.get("platform") or not pga_game["runner"]:
146             continue
147         game = Game(game_id=pga_game["id"])
148         game.set_platform_from_runner()
149         if game.platform:
150             logger.info("Platform for %s set to %s", game.name, game.platform)
151             game.save(save_config=False)
152 
153 
154 def run_all_checks():
155     """Run all startup checks"""
156     check_driver()
157     check_libs()
158     check_vulkan()
159     fill_missing_platforms()
160 
161 
162 def init_lutris():
163     """Run full initialization of Lutris"""
164     logger.info("Starting Lutris %s", settings.VERSION)
165     runners.inject_runners(load_json_runners())
166     # Load runner names and platforms
167     runners.RUNNER_NAMES = runners.get_runner_names()
168     runners.RUNNER_PLATFORMS = runners.get_platforms()
169     init_dirs()
170     try:
171         syncdb()
172     except sqlite3.DatabaseError as err:
173         raise RuntimeError(
174             "Failed to open database file in %s. Try renaming this file and relaunch Lutris" %
175             settings.PGA_DB
176         ) from err
177     for service in DEFAULT_SERVICES:
178         if not settings.read_setting(service, section="services"):
179             settings.write_setting(service, True, section="services")
180 
181 
182 def update_runtime(force=False):
183     """Update runtime components"""
184     runtime_call = update_cache.get_last_call("runtime")
185     if force or not runtime_call or runtime_call > 3600 * 12:
186         runtime_updater = RuntimeUpdater()
187         components_to_update = runtime_updater.update()
188         if components_to_update:
189             while runtime_updater.current_updates:
190                 time.sleep(0.3)
191         update_cache.write_date_to_cache("runtime")
192     for dll_manager_class in (DXVKManager, DXVKNVAPIManager, VKD3DManager, D3DExtrasManager, dgvoodoo2Manager):
193         key = dll_manager_class.__name__
194         key_call = update_cache.get_last_call(key)
195         if force or not key_call or key_call > 3600 * 6:
196             dll_manager = dll_manager_class()
197             dll_manager.upgrade()
198             update_cache.write_date_to_cache(key)
199     media_call = update_cache.get_last_call("media")
200     if force or not media_call or media_call > 3600 * 24:
201         sync_media()
202         update_cache.write_date_to_cache("media")
203     logger.info("Startup complete")
204
```
--- 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/startup.py b/lutris/startup.py
--- a/lutris/startup.py
+++ b/lutris/startup.py
@@ -35,7 +35,7 @@
         os.path.join(settings.DATA_DIR, "covers"),
         settings.ICON_PATH,
         os.path.join(settings.CACHE_DIR, "banners"),
-        os.path.join(settings.DATA_DIR, "coverart"),
+        os.path.join(settings.CACHE_DIR, "coverart"),
         os.path.join(settings.DATA_DIR, "runners"),
         os.path.join(settings.DATA_DIR, "lib"),
         settings.RUNTIME_DIR,

{"golden_diff": "diff --git a/lutris/startup.py b/lutris/startup.py\n--- a/lutris/startup.py\n+++ b/lutris/startup.py\n@@ -35,7 +35,7 @@\n         os.path.join(settings.DATA_DIR, \"covers\"),\n         settings.ICON_PATH,\n         os.path.join(settings.CACHE_DIR, \"banners\"),\n-        os.path.join(settings.DATA_DIR, \"coverart\"),\n+        os.path.join(settings.CACHE_DIR, \"coverart\"),\n         os.path.join(settings.DATA_DIR, \"runners\"),\n         os.path.join(settings.DATA_DIR, \"lib\"),\n         settings.RUNTIME_DIR,\n", "issue": "Lutris doesn't create coverart folder\n### Bug description\r\n\r\nAfter upgrading Lutris to v0.5.10-beta1 at every start a popup is shown with the text\r\n`[Errno 2] No such file or directory: '/home/user/.cache/lutris/coverart'`\r\n\r\nAfter clicking 'OK' Lutris starts normal\r\nRestarting Lutris displays the popup again since the folder isn't created\r\n\r\nManually creating the 'coverart' folder works and Lutris starts fine\r\n\r\n### How to Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n1. Have v0.5.9.1 installed\r\n2. Install v0.5.10-beta1\r\n3. Open Lutris\r\n4. See popup\r\n\r\n### Expected behavior\r\n\r\nLutris shouldn't display a popup but create the missing folder\r\n\r\n### Log output\r\n\r\n```shell\r\nINFO     2022-02-12 17:06:00,408 [startup.init_lutris:164]:Starting Lutris 0.5.10\r\nWARNING  2022-02-12 17:06:00,427 [libretro.get_libretro_cores:48]:No cores found\r\nDEBUG    2022-02-12 17:06:00,432 [xrandr._get_vidmodes:15]:Retrieving video modes from XrandR\r\nINFO     2022-02-12 17:06:00,458 [startup.check_driver:65]:Running AMD Mesa driver 21.3.6 on AMD Radeon RX 5700 (NAVI10, DRM 3.44.0, 5.13.0-generic, LLVM 13.0.0) (0x731f)\r\nINFO     2022-02-12 17:06:00,458 [startup.check_driver:77]:GPU: 1002:731F 148C:2398 (amdgpu drivers)\r\nERROR    2022-02-12 17:06:00,489 [jobs.target:36]:Error while completing task <bound method LutrisInitDialog.initialize of <dialogs.LutrisInitDialog object at 0x7fa950b9aac0 (lutris+gui+dialogs+LutrisInitDialog at 0x1aac2b0)>>: <class 'FileNotFoundError'> [Errno 2] No such file or directory: '/home/user/.cache/lutris/coverart'\r\n  File \"/usr/lib/python3/dist-packages/lutris/util/jobs.py\", line 34, in target\r\n    result = self.function(*args, **kwargs)\r\n  File \"/usr/lib/python3/dist-packages/lutris/gui/dialogs/__init__.py\", line 195, in initialize\r\n    init_lutris()\r\n  File \"/usr/lib/python3/dist-packages/lutris/startup.py\", line 201, in update_runtime\r\n    sync_media()\r\n  File \"/usr/lib/python3/dist-packages/lutris/services/lutris.py\", line 159, in sync_media\r\n    covers_available = {fn.split(\".\")[0] for fn in os.listdir(settings.COVERART_PATH)}\r\n```\r\n\r\n### Checklist:\r\n\r\n- [X] I'm not asking for support with a game or the wine runner.\r\n- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.\r\n- [X] I have checked for existing issues that describe my problem prior to opening this one.\r\n- [X] I understand that improperly formatted bug reports may be closed without explanation.\n", "before_files": [{"content": "\"\"\"Check to run at program start\"\"\"\nimport os\nimport sqlite3\nimport time\nfrom gettext import gettext as _\n\nfrom lutris import runners, settings\nfrom lutris.database.games import get_games\nfrom lutris.database.schema import syncdb\nfrom lutris.game import Game\nfrom lutris.gui.dialogs import DontShowAgainDialog\nfrom lutris.runners.json import load_json_runners\nfrom lutris.runtime import RuntimeUpdater\nfrom lutris.services import DEFAULT_SERVICES\nfrom lutris.services.lutris import sync_media\nfrom lutris.util import update_cache\nfrom lutris.util.graphics import drivers, vkquery\nfrom lutris.util.linux import LINUX_SYSTEM\nfrom lutris.util.log import logger\nfrom lutris.util.system import create_folder\nfrom lutris.util.wine.d3d_extras import D3DExtrasManager\nfrom lutris.util.wine.dgvoodoo2 import dgvoodoo2Manager\nfrom lutris.util.wine.dxvk import DXVKManager\nfrom lutris.util.wine.dxvk_nvapi import DXVKNVAPIManager\nfrom lutris.util.wine.vkd3d import VKD3DManager\n\n\ndef init_dirs():\n    \"\"\"Creates Lutris directories\"\"\"\n    directories = [\n        settings.CONFIG_DIR,\n        os.path.join(settings.CONFIG_DIR, \"runners\"),\n        os.path.join(settings.CONFIG_DIR, \"games\"),\n        settings.DATA_DIR,\n        os.path.join(settings.DATA_DIR, \"covers\"),\n        settings.ICON_PATH,\n        os.path.join(settings.CACHE_DIR, \"banners\"),\n        os.path.join(settings.DATA_DIR, \"coverart\"),\n        os.path.join(settings.DATA_DIR, \"runners\"),\n        os.path.join(settings.DATA_DIR, \"lib\"),\n        settings.RUNTIME_DIR,\n        settings.CACHE_DIR,\n        settings.SHADER_CACHE_DIR,\n        os.path.join(settings.CACHE_DIR, \"installer\"),\n        os.path.join(settings.CACHE_DIR, \"tmp\"),\n    ]\n    for directory in directories:\n        create_folder(directory)\n\n\ndef check_driver():\n    \"\"\"Report on the currently running driver\"\"\"\n    driver_info = {}\n    if drivers.is_nvidia():\n        driver_info = drivers.get_nvidia_driver_info()\n        # pylint: disable=logging-format-interpolation\n        logger.info(\"Using {vendor} drivers {version} for {arch}\".format(**driver_info[\"nvrm\"]))\n        gpus = drivers.get_nvidia_gpu_ids()\n        for gpu_id in gpus:\n            gpu_info = drivers.get_nvidia_gpu_info(gpu_id)\n            logger.info(\"GPU: %s\", gpu_info.get(\"Model\"))\n    elif LINUX_SYSTEM.glxinfo:\n        # pylint: disable=no-member\n        if hasattr(LINUX_SYSTEM.glxinfo, \"GLX_MESA_query_renderer\"):\n            logger.info(\n                \"Running %s Mesa driver %s on %s\",\n                LINUX_SYSTEM.glxinfo.opengl_vendor,\n                LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,\n                LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device,\n            )\n    else:\n        logger.warning(\"glxinfo is not available on your system, unable to detect driver version\")\n\n    for card in drivers.get_gpus():\n        # pylint: disable=logging-format-interpolation\n        try:\n            logger.info(\"GPU: {PCI_ID} {PCI_SUBSYS_ID} ({DRIVER} drivers)\".format(**drivers.get_gpu_info(card)))\n        except KeyError:\n            logger.error(\"Unable to get GPU information from '%s'\", card)\n\n    if drivers.is_outdated():\n        setting = \"hide-outdated-nvidia-driver-warning\"\n        if settings.read_setting(setting) != \"True\":\n            DontShowAgainDialog(\n                setting,\n                _(\"Your NVIDIA driver is outdated.\"),\n                secondary_message=_(\n                    \"You are currently running driver %s which does not \"\n                    \"fully support all features for Vulkan and DXVK games.\\n\"\n                    \"Please upgrade your driver as described in our \"\n                    \"<a href='%s'>installation guide</a>\"\n                ) % (\n                    driver_info[\"nvrm\"][\"version\"],\n                    settings.DRIVER_HOWTO_URL,\n                )\n            )\n\n\ndef check_libs(all_components=False):\n    \"\"\"Checks that required libraries are installed on the system\"\"\"\n    missing_libs = LINUX_SYSTEM.get_missing_libs()\n    if all_components:\n        components = LINUX_SYSTEM.requirements\n    else:\n        components = LINUX_SYSTEM.critical_requirements\n    missing_vulkan_libs = []\n    for req in components:\n        for index, arch in enumerate(LINUX_SYSTEM.runtime_architectures):\n            for lib in missing_libs[req][index]:\n                if req == \"VULKAN\":\n                    missing_vulkan_libs.append(arch)\n                logger.error(\"%s %s missing (needed by %s)\", arch, lib, req.lower())\n\n    if missing_vulkan_libs:\n        setting = \"dismiss-missing-vulkan-library-warning\"\n        if settings.read_setting(setting) != \"True\":\n            DontShowAgainDialog(\n                setting,\n                _(\"Missing vulkan libraries\"),\n                secondary_message=_(\n                    \"Lutris was unable to detect Vulkan support for \"\n                    \"the %s architecture.\\n\"\n                    \"This will prevent many games and programs from working.\\n\"\n                    \"To install it, please use the following guide: \"\n                    \"<a href='%s'>Installing Graphics Drivers</a>\"\n                ) % (\n                    _(\" and \").join(missing_vulkan_libs),\n                    settings.DRIVER_HOWTO_URL,\n                )\n            )\n\n\ndef check_vulkan():\n    \"\"\"Reports if Vulkan is enabled on the system\"\"\"\n    if not vkquery.is_vulkan_supported():\n        logger.warning(\"Vulkan is not available or your system isn't Vulkan capable\")\n\n\ndef fill_missing_platforms():\n    \"\"\"Sets the platform on games where it's missing.\n    This should never happen.\n    \"\"\"\n    pga_games = get_games(filters={\"installed\": 1})\n    for pga_game in pga_games:\n        if pga_game.get(\"platform\") or not pga_game[\"runner\"]:\n            continue\n        game = Game(game_id=pga_game[\"id\"])\n        game.set_platform_from_runner()\n        if game.platform:\n            logger.info(\"Platform for %s set to %s\", game.name, game.platform)\n            game.save(save_config=False)\n\n\ndef run_all_checks():\n    \"\"\"Run all startup checks\"\"\"\n    check_driver()\n    check_libs()\n    check_vulkan()\n    fill_missing_platforms()\n\n\ndef init_lutris():\n    \"\"\"Run full initialization of Lutris\"\"\"\n    logger.info(\"Starting Lutris %s\", settings.VERSION)\n    runners.inject_runners(load_json_runners())\n    # Load runner names and platforms\n    runners.RUNNER_NAMES = runners.get_runner_names()\n    runners.RUNNER_PLATFORMS = runners.get_platforms()\n    init_dirs()\n    try:\n        syncdb()\n    except sqlite3.DatabaseError as err:\n        raise RuntimeError(\n            \"Failed to open database file in %s. Try renaming this file and relaunch Lutris\" %\n            settings.PGA_DB\n        ) from err\n    for service in DEFAULT_SERVICES:\n        if not settings.read_setting(service, section=\"services\"):\n            settings.write_setting(service, True, section=\"services\")\n\n\ndef update_runtime(force=False):\n    \"\"\"Update runtime components\"\"\"\n    runtime_call = update_cache.get_last_call(\"runtime\")\n    if force or not runtime_call or runtime_call > 3600 * 12:\n        runtime_updater = RuntimeUpdater()\n        components_to_update = runtime_updater.update()\n        if components_to_update:\n            while runtime_updater.current_updates:\n                time.sleep(0.3)\n        update_cache.write_date_to_cache(\"runtime\")\n    for dll_manager_class in (DXVKManager, DXVKNVAPIManager, VKD3DManager, D3DExtrasManager, dgvoodoo2Manager):\n        key = dll_manager_class.__name__\n        key_call = update_cache.get_last_call(key)\n        if force or not key_call or key_call > 3600 * 6:\n            dll_manager = dll_manager_class()\n            dll_manager.upgrade()\n            update_cache.write_date_to_cache(key)\n    media_call = update_cache.get_last_call(\"media\")\n    if force or not media_call or media_call > 3600 * 24:\n        sync_media()\n        update_cache.write_date_to_cache(\"media\")\n    logger.info(\"Startup complete\")\n", "path": "lutris/startup.py"}], "after_files": [{"content": "\"\"\"Check to run at program start\"\"\"\nimport os\nimport sqlite3\nimport time\nfrom gettext import gettext as _\n\nfrom lutris import runners, settings\nfrom lutris.database.games import get_games\nfrom lutris.database.schema import syncdb\nfrom lutris.game import Game\nfrom lutris.gui.dialogs import DontShowAgainDialog\nfrom lutris.runners.json import load_json_runners\nfrom lutris.runtime import RuntimeUpdater\nfrom lutris.services import DEFAULT_SERVICES\nfrom lutris.services.lutris import sync_media\nfrom lutris.util import update_cache\nfrom lutris.util.graphics import drivers, vkquery\nfrom lutris.util.linux import LINUX_SYSTEM\nfrom lutris.util.log import logger\nfrom lutris.util.system import create_folder\nfrom lutris.util.wine.d3d_extras import D3DExtrasManager\nfrom lutris.util.wine.dgvoodoo2 import dgvoodoo2Manager\nfrom lutris.util.wine.dxvk import DXVKManager\nfrom lutris.util.wine.dxvk_nvapi import DXVKNVAPIManager\nfrom lutris.util.wine.vkd3d import VKD3DManager\n\n\ndef init_dirs():\n    \"\"\"Creates Lutris directories\"\"\"\n    directories = [\n        settings.CONFIG_DIR,\n        os.path.join(settings.CONFIG_DIR, \"runners\"),\n        os.path.join(settings.CONFIG_DIR, \"games\"),\n        settings.DATA_DIR,\n        os.path.join(settings.DATA_DIR, \"covers\"),\n        settings.ICON_PATH,\n        os.path.join(settings.CACHE_DIR, \"banners\"),\n        os.path.join(settings.CACHE_DIR, \"coverart\"),\n        os.path.join(settings.DATA_DIR, \"runners\"),\n        os.path.join(settings.DATA_DIR, \"lib\"),\n        settings.RUNTIME_DIR,\n        settings.CACHE_DIR,\n        settings.SHADER_CACHE_DIR,\n        os.path.join(settings.CACHE_DIR, \"installer\"),\n        os.path.join(settings.CACHE_DIR, \"tmp\"),\n    ]\n    for directory in directories:\n        create_folder(directory)\n\n\ndef check_driver():\n    \"\"\"Report on the currently running driver\"\"\"\n    driver_info = {}\n    if drivers.is_nvidia():\n        driver_info = drivers.get_nvidia_driver_info()\n        # pylint: disable=logging-format-interpolation\n        logger.info(\"Using {vendor} drivers {version} for {arch}\".format(**driver_info[\"nvrm\"]))\n        gpus = drivers.get_nvidia_gpu_ids()\n        for gpu_id in gpus:\n            gpu_info = drivers.get_nvidia_gpu_info(gpu_id)\n            logger.info(\"GPU: %s\", gpu_info.get(\"Model\"))\n    elif LINUX_SYSTEM.glxinfo:\n        # pylint: disable=no-member\n        if hasattr(LINUX_SYSTEM.glxinfo, \"GLX_MESA_query_renderer\"):\n            logger.info(\n                \"Running %s Mesa driver %s on %s\",\n                LINUX_SYSTEM.glxinfo.opengl_vendor,\n                LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.version,\n                LINUX_SYSTEM.glxinfo.GLX_MESA_query_renderer.device,\n            )\n    else:\n        logger.warning(\"glxinfo is not available on your system, unable to detect driver version\")\n\n    for card in drivers.get_gpus():\n        # pylint: disable=logging-format-interpolation\n        try:\n            logger.info(\"GPU: {PCI_ID} {PCI_SUBSYS_ID} ({DRIVER} drivers)\".format(**drivers.get_gpu_info(card)))\n        except KeyError:\n            logger.error(\"Unable to get GPU information from '%s'\", card)\n\n    if drivers.is_outdated():\n        setting = \"hide-outdated-nvidia-driver-warning\"\n        if settings.read_setting(setting) != \"True\":\n            DontShowAgainDialog(\n                setting,\n                _(\"Your NVIDIA driver is outdated.\"),\n                secondary_message=_(\n                    \"You are currently running driver %s which does not \"\n                    \"fully support all features for Vulkan and DXVK games.\\n\"\n                    \"Please upgrade your driver as described in our \"\n                    \"<a href='%s'>installation guide</a>\"\n                ) % (\n                    driver_info[\"nvrm\"][\"version\"],\n                    settings.DRIVER_HOWTO_URL,\n                )\n            )\n\n\ndef check_libs(all_components=False):\n    \"\"\"Checks that required libraries are installed on the system\"\"\"\n    missing_libs = LINUX_SYSTEM.get_missing_libs()\n    if all_components:\n        components = LINUX_SYSTEM.requirements\n    else:\n        components = LINUX_SYSTEM.critical_requirements\n    missing_vulkan_libs = []\n    for req in components:\n        for index, arch in enumerate(LINUX_SYSTEM.runtime_architectures):\n            for lib in missing_libs[req][index]:\n                if req == \"VULKAN\":\n                    missing_vulkan_libs.append(arch)\n                logger.error(\"%s %s missing (needed by %s)\", arch, lib, req.lower())\n\n    if missing_vulkan_libs:\n        setting = \"dismiss-missing-vulkan-library-warning\"\n        if settings.read_setting(setting) != \"True\":\n            DontShowAgainDialog(\n                setting,\n                _(\"Missing vulkan libraries\"),\n                secondary_message=_(\n                    \"Lutris was unable to detect Vulkan support for \"\n                    \"the %s architecture.\\n\"\n                    \"This will prevent many games and programs from working.\\n\"\n                    \"To install it, please use the following guide: \"\n                    \"<a href='%s'>Installing Graphics Drivers</a>\"\n                ) % (\n                    _(\" and \").join(missing_vulkan_libs),\n                    settings.DRIVER_HOWTO_URL,\n                )\n            )\n\n\ndef check_vulkan():\n    \"\"\"Reports if Vulkan is enabled on the system\"\"\"\n    if not vkquery.is_vulkan_supported():\n        logger.warning(\"Vulkan is not available or your system isn't Vulkan capable\")\n\n\ndef fill_missing_platforms():\n    \"\"\"Sets the platform on games where it's missing.\n    This should never happen.\n    \"\"\"\n    pga_games = get_games(filters={\"installed\": 1})\n    for pga_game in pga_games:\n        if pga_game.get(\"platform\") or not pga_game[\"runner\"]:\n            continue\n        game = Game(game_id=pga_game[\"id\"])\n        game.set_platform_from_runner()\n        if game.platform:\n            logger.info(\"Platform for %s set to %s\", game.name, game.platform)\n            game.save(save_config=False)\n\n\ndef run_all_checks():\n    \"\"\"Run all startup checks\"\"\"\n    check_driver()\n    check_libs()\n    check_vulkan()\n    fill_missing_platforms()\n\n\ndef init_lutris():\n    \"\"\"Run full initialization of Lutris\"\"\"\n    logger.info(\"Starting Lutris %s\", settings.VERSION)\n    runners.inject_runners(load_json_runners())\n    # Load runner names and platforms\n    runners.RUNNER_NAMES = runners.get_runner_names()\n    runners.RUNNER_PLATFORMS = runners.get_platforms()\n    init_dirs()\n    try:\n        syncdb()\n    except sqlite3.DatabaseError as err:\n        raise RuntimeError(\n            \"Failed to open database file in %s. Try renaming this file and relaunch Lutris\" %\n            settings.PGA_DB\n        ) from err\n    for service in DEFAULT_SERVICES:\n        if not settings.read_setting(service, section=\"services\"):\n            settings.write_setting(service, True, section=\"services\")\n\n\ndef update_runtime(force=False):\n    \"\"\"Update runtime components\"\"\"\n    runtime_call = update_cache.get_last_call(\"runtime\")\n    if force or not runtime_call or runtime_call > 3600 * 12:\n        runtime_updater = RuntimeUpdater()\n        components_to_update = runtime_updater.update()\n        if components_to_update:\n            while runtime_updater.current_updates:\n                time.sleep(0.3)\n        update_cache.write_date_to_cache(\"runtime\")\n    for dll_manager_class in (DXVKManager, DXVKNVAPIManager, VKD3DManager, D3DExtrasManager, dgvoodoo2Manager):\n        key = dll_manager_class.__name__\n        key_call = update_cache.get_last_call(key)\n        if force or not key_call or key_call > 3600 * 6:\n            dll_manager = dll_manager_class()\n            dll_manager.upgrade()\n            update_cache.write_date_to_cache(key)\n    media_call = update_cache.get_last_call(\"media\")\n    if force or not media_call or media_call > 3600 * 24:\n        sync_media()\n        update_cache.write_date_to_cache(\"media\")\n    logger.info(\"Startup complete\")\n", "path": "lutris/startup.py"}]}