Fix mrpack index: include sha512 hashes (Prism import validator)
This commit is contained in:
Binary file not shown.
+8
-1
@@ -41,6 +41,13 @@ def sha1(path):
|
|||||||
h.update(block)
|
h.update(block)
|
||||||
return h.hexdigest()
|
return h.hexdigest()
|
||||||
|
|
||||||
|
def sha512(path):
|
||||||
|
h = hashlib.sha512()
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
for block in iter(lambda: f.read(65536), b""):
|
||||||
|
h.update(block)
|
||||||
|
return h.hexdigest()
|
||||||
|
|
||||||
def resolve(sha):
|
def resolve(sha):
|
||||||
url = f"https://api.modrinth.com/v2/version_file/{sha}?algorithm=sha1"
|
url = f"https://api.modrinth.com/v2/version_file/{sha}?algorithm=sha1"
|
||||||
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
|
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})
|
||||||
@@ -64,7 +71,7 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
files.append({
|
files.append({
|
||||||
"path": "mods/" + fname,
|
"path": "mods/" + fname,
|
||||||
"hashes": {"sha1": sha1(path)},
|
"hashes": {"sha1": sha1(path), "sha512": sha512(path)},
|
||||||
"env": {"client": "required", "server": "optional"},
|
"env": {"client": "required", "server": "optional"},
|
||||||
"downloads": [url],
|
"downloads": [url],
|
||||||
"fileSize": fsize,
|
"fileSize": fsize,
|
||||||
|
|||||||
Reference in New Issue
Block a user