summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2024-07-05 09:32:52 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2025-03-02 13:43:37 +0200
commit535614dcc863108fa5af1568e35d6284b8889bc2 (patch)
tree11a591ae312e5f208800e010c8bdd254347a3c8a /meta
parentb95b59986cd81eb9e577a32cfbd48060026be0c2 (diff)
downloadProject-Tick-535614dcc863108fa5af1568e35d6284b8889bc2.tar.gz
Project-Tick-535614dcc863108fa5af1568e35d6284b8889bc2.zip
check sha1 for forge/neoforge maven
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/common/__init__.py9
-rwxr-xr-xmeta/run/update_forge.py20
-rw-r--r--meta/run/update_neoforge.py20
3 files changed, 47 insertions, 2 deletions
diff --git a/meta/common/__init__.py b/meta/common/__init__.py
index d7ee49ac4a..16a4f507bf 100644
--- a/meta/common/__init__.py
+++ b/meta/common/__init__.py
@@ -86,3 +86,12 @@ def default_session():
sess.headers.update({"User-Agent": "PrismLauncherMeta/1.0"})
return sess
+
+
+def remove_files(file_paths):
+ for file_path in file_paths:
+ try:
+ if os.path.isfile(file_path):
+ os.remove(file_path)
+ except Exception as e:
+ print(e)
diff --git a/meta/run/update_forge.py b/meta/run/update_forge.py
index 8fc8920bad..5a86727199 100755
--- a/meta/run/update_forge.py
+++ b/meta/run/update_forge.py
@@ -16,7 +16,12 @@ from pprint import pprint
from pydantic import ValidationError
-from meta.common import upstream_path, ensure_upstream_dir, default_session
+from meta.common import (
+ upstream_path,
+ ensure_upstream_dir,
+ default_session,
+ remove_files,
+)
from meta.common.forge import (
JARS_DIR,
INSTALLER_INFO_DIR,
@@ -292,6 +297,19 @@ def main():
UPSTREAM_DIR + "/forge/version_manifests/%s.json" % version.long_version
)
+ if not os.path.isfile(jar_path):
+ remove_files([profile_path, installer_info_path])
+ else:
+ fileSha1 = filehash(jar_path, hashlib.sha1)
+ try:
+ rfile = sess.get(version.url() + ".sha1")
+ rfile.raise_for_status()
+ if fileSha1 != rfile.text.strip():
+ remove_files([jar_path, profile_path, installer_info_path])
+ 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 60b94ec6b1..c6eb0f3cd4 100644
--- a/meta/run/update_neoforge.py
+++ b/meta/run/update_neoforge.py
@@ -17,7 +17,12 @@ import urllib.parse
from pydantic import ValidationError
-from meta.common import upstream_path, ensure_upstream_dir, default_session
+from meta.common import (
+ upstream_path,
+ ensure_upstream_dir,
+ default_session,
+ remove_files,
+)
from meta.common.neoforge import (
JARS_DIR,
INSTALLER_INFO_DIR,
@@ -243,6 +248,19 @@ def main():
UPSTREAM_DIR + "/neoforge/version_manifests/%s.json" % version.long_version
)
+ if not os.path.isfile(jar_path):
+ remove_files([profile_path, installer_info_path])
+ else:
+ fileSha1 = filehash(jar_path, hashlib.sha1)
+ try:
+ rfile = sess.get(version.url() + ".sha1")
+ rfile.raise_for_status()
+ if fileSha1 != rfile.text.strip():
+ remove_files([jar_path, profile_path, installer_info_path])
+ 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)