From dcb36ffbde6a26fc6bbd65183a286b3fd8497b2d Mon Sep 17 00:00:00 2001 From: Benjamin Wrensch Date: Tue, 18 Jun 2024 20:32:42 +0200 Subject: [PATCH] [fix] only write out the plugin build metadata if at least one plugin has been found --- iolite_plugins/update_build_metadata.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/iolite_plugins/update_build_metadata.py b/iolite_plugins/update_build_metadata.py index 7b67ac8..f90240d 100644 --- a/iolite_plugins/update_build_metadata.py +++ b/iolite_plugins/update_build_metadata.py @@ -19,8 +19,9 @@ def hash_djb2(b): ] platforms = [("windows", "dll"), ("linux", "so")] - for plat in platforms: + any_plugin_found = False + for p in plugins: dll_filepath = "{}/{}.{}".format(plat[0], p["filename"], plat[1]) json_filepath = "{}/plugins.json".format(plat[0]) @@ -31,6 +32,13 @@ def hash_djb2(b): checksum = hash_djb2(plugin_data) checksum_with_salt = hash_djb2(bytes("{}{}".format(checksum, sys.argv[1]), "ascii")) p["checksum"] = checksum_with_salt - - with open(json_filepath, "w") as plugins_json: - json.dump(plugins, plugins_json, indent=2) + any_plugin_found = True + else: + print("Plugin '{}' not found. Skipping checksum generation...".format(dll_filepath)) + + # Only write the file if we've found at least one of the plugins + if any_plugin_found: + with open(json_filepath, "w") as plugins_json: + json.dump(plugins, plugins_json, indent=2) + else: + print("No plugins found for platform '{}'. Not writing 'plugins.json' file...".format(plat[0]))