🐛 Fixed import

This commit is contained in:
GeoffreyCoulaud
2023-05-09 14:45:40 +02:00
parent 78b91c0d52
commit c647ca1a31
2 changed files with 10 additions and 4 deletions

View File

@@ -74,10 +74,10 @@ class Importer:
# Scan sources in threads # Scan sources in threads
threads = [] threads = []
for source in self.sources: 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: if not source.is_installed:
continue 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) threads.append(t)
t.start() t.start()
@@ -86,18 +86,23 @@ class Importer:
# Save games # Save games
for game in self.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() game.save()
self.close_dialog() self.close_dialog()
def __import_source(self, *args, **kwargs): def __import_source__(self, *args, **kwargs):
"""Source import thread entry point""" """Source import thread entry point"""
# TODO error handling in source iteration # TODO error handling in source iteration
# TODO add SGDB image (move to a game manager) # TODO add SGDB image (move to a game manager)
source, *rest = args source, *rest = args
iterator = source.__iter__() iterator = source.__iter__()
with self.progress_lock: with self.progress_lock:
self.counts[source.id]["total"] = iterator.__len__() self.counts[source.id]["total"] = len(iterator)
for game in iterator: for game in iterator:
with self.games_lock: with self.games_lock:
self.games.add(game) self.games.add(game)

View File

@@ -67,6 +67,7 @@ class LutrisSourceIterator(SourceIterator):
# Create game # Create game
values = { values = {
"added": int(time()), "added": int(time()),
"last_played": 0,
"hidden": row[4], "hidden": row[4],
"name": row[1], "name": row[1],
"source": f"{self.source.id}_{row[3]}", "source": f"{self.source.id}_{row[3]}",