From c647ca1a3133069013a98d982516f09104ab34ed Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Tue, 9 May 2023 14:45:40 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/importer/importer.py | 13 +++++++++---- src/importer/sources/lutris_source.py | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/importer/importer.py b/src/importer/importer.py index de6256a..2015a04 100644 --- a/src/importer/importer.py +++ b/src/importer/importer.py @@ -74,10 +74,10 @@ class Importer: # Scan sources in threads threads = [] for source in self.sources: - print(f"{source.full_name}, installed: {source.is_installed}") # ! DEBUG + print(f"{source.full_name}, installed: {source.is_installed}") if not source.is_installed: continue - t = Thread(target=self.__import_source, args=tuple([source])) # fmt: skip + t = Thread(target=self.__import_source__, args=tuple([source])) # fmt: skip threads.append(t) t.start() @@ -86,18 +86,23 @@ class Importer: # Save games for game in self.games: + if ( + game.game_id in self.win.games + and not self.win.games[game.game_id].removed + ): + continue game.save() self.close_dialog() - def __import_source(self, *args, **kwargs): + def __import_source__(self, *args, **kwargs): """Source import thread entry point""" # TODO error handling in source iteration # TODO add SGDB image (move to a game manager) source, *rest = args iterator = source.__iter__() with self.progress_lock: - self.counts[source.id]["total"] = iterator.__len__() + self.counts[source.id]["total"] = len(iterator) for game in iterator: with self.games_lock: self.games.add(game) diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index c59a7ad..44e6bea 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -67,6 +67,7 @@ class LutrisSourceIterator(SourceIterator): # Create game values = { "added": int(time()), + "last_played": 0, "hidden": row[4], "name": row[1], "source": f"{self.source.id}_{row[3]}",