From 3919346cb4e4dc09ed540644baf042a5e1ac68c2 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 17 Dec 2019 10:09:19 -0800 Subject: [PATCH] Initialize sources on first update --- inquisitor/importer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inquisitor/importer.py b/inquisitor/importer.py index 60d7efe..bf37ff1 100644 --- a/inquisitor/importer.py +++ b/inquisitor/importer.py @@ -16,6 +16,18 @@ def update_sources(*source_names): error.as_item("Error importing source '{}'".format(source_name), traceback.format_exc()) continue + cell_path = os.path.join(DUNGEON_PATH, source_name) + if not os.path.isdir(cell_path): + try: + logger.info("Creating cell for source '{}'".format(source_name)) + os.mkdir(cell_path) + state_path = os.path.join(cell_path, "state") + with open(state_path, 'w', encoding='utf8') as f: + f.write(json.dumps({})) + except Exception as e: + error.as_item("Error initializing source '{}'".format(source_name), traceback.format_exc()) + continue + try: logger.info("Updating source '{}'".format(source_name)) new_count, del_count = update_source(source_name, source_module.fetch_new)