Various fixes

This commit is contained in:
GeoffreyCoulaud
2023-05-24 17:30:19 +02:00
parent 7220852291
commit 8da7185d17
6 changed files with 9 additions and 12 deletions

View File

@@ -11,5 +11,4 @@ class FileManager(Manager):
run_after = set((SteamAPIManager, SGDBManager, FormatUpdateManager))
def run(self, game: Game) -> None:
# TODO make game.save (disk) not trigger game.update (UI)
game.save()

View File

@@ -16,5 +16,4 @@ class FormatUpdateManager(Manager):
def run(self, game: Game) -> None:
if game.version is None:
self.v1_5_to_v2_0(game)
# TODO make game.save (disk) not trigger game.update (UI)
game.save()

View File

@@ -12,7 +12,7 @@ class Manager:
in that case a new cancellable must be generated for new tasks to run.
"""
run_after: set[type["Manager"]]
run_after: set[type["Manager"]] = set()
cancellable: Gio.Cancellable
errors: list[Exception]
@@ -42,7 +42,7 @@ class Manager:
return errors
@abstractmethod
def run(self, game: Game) -> None:
def run(self, game: Game, cancellable: Gio.Cancellable) -> None:
"""Pass the game through the manager.
May block its thread.
May not raise exceptions, as they will be silently ignored."""

View File

@@ -17,8 +17,9 @@ class Pipeline(GObject.Object):
running: set[Manager]
done: set[Manager]
def __init__(self, managers: Iterable[Manager]) -> None:
def __init__(self, game: Game, managers: Iterable[Manager]) -> None:
super().__init__()
self.game = game
self.waiting = set(managers)
self.running = set()
self.done = set()
@@ -26,7 +27,7 @@ class Pipeline(GObject.Object):
@property
def not_done(self) -> set[Manager]:
"""Get the managers that are not done yet"""
return self.waiting + self.running
return self.waiting | self.running
@property
def blocked(self) -> set[Manager]:
@@ -64,7 +65,7 @@ class Pipeline(GObject.Object):
"""Thread function for manager tasks"""
manager, *_rest = data
self.emit("manager-started", manager)
manager.run(self.game, cancellable)
manager.run(self.game)
@GObject.Signal(name="manager-done", arg_types=(object,))
def manager_done(self, manager: Manager) -> None:
@@ -115,7 +116,7 @@ class Store:
return None
# Cleanup removed games
if game.get("removed"):
if game.removed:
for path in (
shared.games_dir / f"{game.game_id}.json",
shared.covers_dir / f"{game.game_id}.tiff",
@@ -125,7 +126,7 @@ class Store:
return None
# Run the pipeline for the game
pipeline = Pipeline(self.managers)
pipeline = Pipeline(game, self.managers)
self.games[game.game_id] = game
self.pipelines[game.game_id] = pipeline
pipeline.advance()