Handle bogus sources gracefully
This commit is contained in:
@@ -136,9 +136,11 @@ class Importer(ErrorProducer):
|
||||
task = Gio.Task.new(None, None, self.source_callback, (source,))
|
||||
self.n_source_tasks_created += 1
|
||||
task.run_in_thread(
|
||||
lambda _task, _obj, _data, _cancellable, src=source: self.source_task_thread_func(
|
||||
(src,)
|
||||
)
|
||||
lambda _task,
|
||||
_obj,
|
||||
_data,
|
||||
_cancellable,
|
||||
src=source: self.source_task_thread_func((src,))
|
||||
)
|
||||
|
||||
# Workaround: Adw bug: Dialog won't close if closed too soon after opening
|
||||
@@ -150,7 +152,6 @@ class Importer(ErrorProducer):
|
||||
self.import_dialog.force_close()
|
||||
return shared.win.get_visible_dialog() == self.import_dialog
|
||||
|
||||
|
||||
def monitor_import(self) -> bool:
|
||||
"""Monitor import progress to update dialog and to trigger import cleanup
|
||||
once the work has finished"""
|
||||
@@ -185,12 +186,16 @@ class Importer(ErrorProducer):
|
||||
if not shared.schema.get_boolean("remove-missing"):
|
||||
return
|
||||
|
||||
keys = shared.schema.list_keys()
|
||||
|
||||
for game in shared.store:
|
||||
if game.removed:
|
||||
continue
|
||||
if game.source == "imported":
|
||||
continue
|
||||
if not shared.schema.get_boolean(game.base_source):
|
||||
if (game.base_source in keys) and (
|
||||
not shared.schema.get_boolean(game.base_source)
|
||||
):
|
||||
continue
|
||||
if game.game_id in shared.store.duplicate_game_ids:
|
||||
continue
|
||||
|
||||
@@ -250,7 +250,10 @@ class CartridgesApplication(Adw.Application):
|
||||
elif source_id == "imported":
|
||||
name = _("Added")
|
||||
else:
|
||||
name = globals()[f'{source_id.split("_")[0].title()}Source'].name
|
||||
try:
|
||||
name = globals()[f"{source_id.split('_')[0].title()}Source"].name
|
||||
except KeyError:
|
||||
return source_id
|
||||
return name
|
||||
|
||||
def on_about_action(self, *_args: Any) -> None:
|
||||
|
||||
Reference in New Issue
Block a user