From 9dd74cdf487e19a3cf0b60c224a2c798471a493a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 21 Mar 2026 11:40:11 +0200 Subject: update sha1 cahcing check Signed-off-by: Trial97 --- meta/common/__init__.py | 3 ++- meta/run/update_forge.py | 23 ++++++++++------------- meta/run/update_neoforge.py | 23 ++++++++++------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/meta/common/__init__.py b/meta/common/__init__.py index 1f358cdbd7..533f832917 100644 --- a/meta/common/__init__.py +++ b/meta/common/__init__.py @@ -117,7 +117,8 @@ def get_file_sha1_from_file(file_name: str, sha1_file: str) -> Optional[str]: if os.path.isfile(sha1_file): with open(sha1_file, "r") as file: return file.read() - + if not os.path.isfile(jar_path): + return None new_sha1 = file_hash(file_name, hashlib.sha1) with open(sha1_file, "w") as file: file.write(new_sha1) diff --git a/meta/run/update_forge.py b/meta/run/update_forge.py index 23ad333955..c74865b31f 100755 --- a/meta/run/update_forge.py +++ b/meta/run/update_forge.py @@ -150,19 +150,16 @@ def process_forge_version(version, jar_path): new_sha1 = None sha1_file = jar_path + ".sha1" - if not os.path.isfile(jar_path): - remove_files([profile_path, installer_info_path]) - else: - fileSha1 = get_file_sha1_from_file(jar_path, sha1_file) - try: - rfile = sess.get(version.url() + ".sha1") - rfile.raise_for_status() - new_sha1 = rfile.text.strip() - if fileSha1 != new_sha1: - remove_files([jar_path, profile_path, installer_info_path, sha1_file]) - except Exception as e: - eprint("Failed to check sha1 %s" % version.url()) - eprint("Error is %s" % e) + fileSha1 = get_file_sha1_from_file(jar_path, sha1_file) + try: + rfile = sess.get(version.url() + ".sha1") + rfile.raise_for_status() + new_sha1 = rfile.text.strip() + if fileSha1 != new_sha1: + remove_files([jar_path, profile_path, installer_info_path, sha1_file]) + except Exception as e: + eprint("Failed to check sha1 %s" % version.url()) + eprint("Error is %s" % e) installer_refresh_required = not os.path.isfile(profile_path) or not os.path.isfile( installer_info_path diff --git a/meta/run/update_neoforge.py b/meta/run/update_neoforge.py index 242ad8a6b1..9957aad1bd 100644 --- a/meta/run/update_neoforge.py +++ b/meta/run/update_neoforge.py @@ -141,19 +141,16 @@ def process_neoforge_version(key, entry): new_sha1 = None sha1_file = jar_path + ".sha1" - if not os.path.isfile(jar_path): - remove_files([profile_path, installer_info_path]) - else: - fileSha1 = get_file_sha1_from_file(jar_path, sha1_file) - try: - rfile = sess.get(version.url() + ".sha1") - rfile.raise_for_status() - new_sha1 = rfile.text.strip() - if fileSha1 != new_sha1: - remove_files([jar_path, profile_path, installer_info_path, sha1_file]) - except Exception as e: - eprint("Failed to check sha1 %s" % version.url()) - eprint("Error is %s" % e) + fileSha1 = get_file_sha1_from_file(jar_path, sha1_file) + try: + rfile = sess.get(version.url() + ".sha1") + rfile.raise_for_status() + new_sha1 = rfile.text.strip() + if fileSha1 != new_sha1: + remove_files([jar_path, profile_path, installer_info_path, sha1_file]) + except Exception as e: + eprint("Failed to check sha1 %s" % version.url()) + eprint("Error is %s" % e) installer_refresh_required = not os.path.isfile(profile_path) or not os.path.isfile( installer_info_path -- cgit 0.0.5-2-1-g0f52