Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions meta/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 19 additions & 1 deletion meta/run/update_forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

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,
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion meta/run/update_neoforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

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,
Expand Down Expand Up @@ -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)
Expand Down