Fix import hanging if custom Bottles location

This commit is contained in:
kramo
2023-06-10 18:45:56 +02:00
parent 5fadaf8537
commit 49769b7083

View File

@@ -83,15 +83,25 @@ def bottles_importer():
values["added"] = current_time values["added"] = current_time
values["last_played"] = 0 values["last_played"] = 0
importer.save_game( # This will not work if both Cartridges and Bottles are installed via Flatpak
values, # as Cartridges can't access directories picked via Bottles' file picker portal
( try:
bottles_dir bottles_location = Path(
/ "bottles" yaml.safe_load((bottles_dir / "data.yml").read_text("utf-8"))[
"custom_bottles_path"
]
)
except (FileNotFoundError, KeyError):
bottles_location = bottles_dir / "bottles"
grid_path = (
bottles_location
/ game["bottle"]["path"] / game["bottle"]["path"]
/ "grids" / "grids"
/ game["thumbnail"].split(":")[1] / game["thumbnail"].split(":")[1]
) )
if game["thumbnail"]
else None, importer.save_game(
values,
grid_path if game["thumbnail"] and grid_path.is_file() else None,
) )