Skip to content

Commit

Permalink
Fix import hanging if custom Bottles location
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Jun 10, 2023
1 parent 5fadaf8 commit 49769b7
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/importers/bottles_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,25 @@ def bottles_importer():
values["added"] = current_time
values["last_played"] = 0

# This will not work if both Cartridges and Bottles are installed via Flatpak
# as Cartridges can't access directories picked via Bottles' file picker portal
try:
bottles_location = Path(
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"]
/ "grids"
/ game["thumbnail"].split(":")[1]
)

importer.save_game(
values,
(
bottles_dir
/ "bottles"
/ game["bottle"]["path"]
/ "grids"
/ game["thumbnail"].split(":")[1]
)
if game["thumbnail"]
else None,
grid_path if game["thumbnail"] and grid_path.is_file() else None,
)

0 comments on commit 49769b7

Please sign in to comment.