mirror of
https://github.com/unmojang/meta.git
synced 2025-09-24 03:31:03 -04:00
refactor: remove unused metadata
This should reduce the amount of times we would need to download JAR files for Fabric or Quilt
This commit is contained in:
parent
e823ee4a4b
commit
07b05bd815
@ -38,6 +38,3 @@ class FabricInstallerDataV1(MetaBase):
|
|||||||
|
|
||||||
class FabricJarInfo(MetaBase):
|
class FabricJarInfo(MetaBase):
|
||||||
release_time: Optional[datetime] = Field(alias="releaseTime")
|
release_time: Optional[datetime] = Field(alias="releaseTime")
|
||||||
size: Optional[int]
|
|
||||||
sha256: Optional[str]
|
|
||||||
sha1: Optional[str]
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -46,12 +45,6 @@ def get_json_file(path, url):
|
|||||||
return version_json
|
return version_json
|
||||||
|
|
||||||
|
|
||||||
def get_plaintext(url):
|
|
||||||
r = sess.get(url)
|
|
||||||
r.raise_for_status()
|
|
||||||
return r.text
|
|
||||||
|
|
||||||
|
|
||||||
def head_file(url):
|
def head_file(url):
|
||||||
r = sess.head(url)
|
r = sess.head(url)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
@ -73,11 +66,8 @@ def compute_jar_file(path, url):
|
|||||||
# Let's not download a Jar file if we don't need to.
|
# Let's not download a Jar file if we don't need to.
|
||||||
headers = head_file(url)
|
headers = head_file(url)
|
||||||
tstamp = datetime.strptime(headers["Last-Modified"], DATETIME_FORMAT_HTTP)
|
tstamp = datetime.strptime(headers["Last-Modified"], DATETIME_FORMAT_HTTP)
|
||||||
sha1 = get_plaintext(url + ".sha1")
|
|
||||||
sha256 = get_plaintext(url + ".sha256")
|
|
||||||
size = int(headers["Content-Length"])
|
|
||||||
except requests.HTTPError:
|
except requests.HTTPError:
|
||||||
# Some older versions don't have a .sha256 file :(
|
# Just in case something changes in the future
|
||||||
print(f"Falling back to downloading jar for {url}")
|
print(f"Falling back to downloading jar for {url}")
|
||||||
|
|
||||||
jar_path = path + ".jar"
|
jar_path = path + ".jar"
|
||||||
@ -90,11 +80,7 @@ def compute_jar_file(path, url):
|
|||||||
if tstamp_new > tstamp:
|
if tstamp_new > tstamp:
|
||||||
tstamp = tstamp_new
|
tstamp = tstamp_new
|
||||||
|
|
||||||
sha1 = filehash(jar_path, hashlib.sha1)
|
data = FabricJarInfo(release_time=tstamp)
|
||||||
sha256 = filehash(jar_path, hashlib.sha256)
|
|
||||||
size = os.path.getsize(jar_path)
|
|
||||||
|
|
||||||
data = FabricJarInfo(release_time=tstamp, sha1=sha1, sha256=sha256, size=size)
|
|
||||||
data.write(path + ".json")
|
data.write(path + ".json")
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +98,7 @@ def main():
|
|||||||
with open(os.path.join(UPSTREAM_DIR, META_DIR, "loader.json"), 'r', encoding='utf-8') as loaderVersionIndexFile:
|
with open(os.path.join(UPSTREAM_DIR, META_DIR, "loader.json"), 'r', encoding='utf-8') as loaderVersionIndexFile:
|
||||||
loader_version_index = json.load(loaderVersionIndexFile)
|
loader_version_index = json.load(loaderVersionIndexFile)
|
||||||
for it in loader_version_index:
|
for it in loader_version_index:
|
||||||
print(f"Downloading installer info for loader {it['version']} ")
|
print(f"Downloading JAR info for loader {it['version']} ")
|
||||||
maven_url = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".json")
|
maven_url = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".json")
|
||||||
get_json_file(os.path.join(UPSTREAM_DIR, INSTALLER_INFO_DIR, f"{it['version']}.json"), maven_url)
|
get_json_file(os.path.join(UPSTREAM_DIR, INSTALLER_INFO_DIR, f"{it['version']}.json"), maven_url)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -47,12 +46,6 @@ def get_json_file(path, url):
|
|||||||
return version_json
|
return version_json
|
||||||
|
|
||||||
|
|
||||||
def get_plaintext(url):
|
|
||||||
r = sess.get(url)
|
|
||||||
r.raise_for_status()
|
|
||||||
return r.text
|
|
||||||
|
|
||||||
|
|
||||||
def head_file(url):
|
def head_file(url):
|
||||||
r = sess.head(url)
|
r = sess.head(url)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
@ -74,11 +67,8 @@ def compute_jar_file(path, url):
|
|||||||
# Let's not download a Jar file if we don't need to.
|
# Let's not download a Jar file if we don't need to.
|
||||||
headers = head_file(url)
|
headers = head_file(url)
|
||||||
tstamp = datetime.strptime(headers["Last-Modified"], DATETIME_FORMAT_HTTP)
|
tstamp = datetime.strptime(headers["Last-Modified"], DATETIME_FORMAT_HTTP)
|
||||||
sha1 = get_plaintext(url + ".sha1")
|
|
||||||
sha256 = get_plaintext(url + ".sha256")
|
|
||||||
size = int(headers["Content-Length"])
|
|
||||||
except requests.HTTPError:
|
except requests.HTTPError:
|
||||||
# Some older versions don't have a .sha256 file :(
|
# Just in case something changes in the future
|
||||||
print(f"Falling back to downloading jar for {url}")
|
print(f"Falling back to downloading jar for {url}")
|
||||||
|
|
||||||
jar_path = path + ".jar"
|
jar_path = path + ".jar"
|
||||||
@ -91,11 +81,7 @@ def compute_jar_file(path, url):
|
|||||||
if tstamp_new > tstamp:
|
if tstamp_new > tstamp:
|
||||||
tstamp = tstamp_new
|
tstamp = tstamp_new
|
||||||
|
|
||||||
sha1 = filehash(jar_path, hashlib.sha1)
|
data = FabricJarInfo(release_time=tstamp)
|
||||||
sha256 = filehash(jar_path, hashlib.sha256)
|
|
||||||
size = os.path.getsize(jar_path)
|
|
||||||
|
|
||||||
data = FabricJarInfo(release_time=tstamp, sha1=sha1, sha256=sha256, size=size)
|
|
||||||
data.write(path + ".json")
|
data.write(path + ".json")
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +102,7 @@ def main():
|
|||||||
with open(os.path.join(UPSTREAM_DIR, META_DIR, "loader.json"), 'r', encoding='utf-8') as loaderVersionIndexFile:
|
with open(os.path.join(UPSTREAM_DIR, META_DIR, "loader.json"), 'r', encoding='utf-8') as loaderVersionIndexFile:
|
||||||
loader_version_index = json.load(loaderVersionIndexFile)
|
loader_version_index = json.load(loaderVersionIndexFile)
|
||||||
for it in loader_version_index:
|
for it in loader_version_index:
|
||||||
print(f"Downloading installer info for loader {it['version']} ")
|
print(f"Downloading JAR info for loader {it['version']} ")
|
||||||
maven_url = get_maven_url(it["maven"], "https://maven.quiltmc.org/repository/release/", ".json")
|
maven_url = get_maven_url(it["maven"], "https://maven.quiltmc.org/repository/release/", ".json")
|
||||||
get_json_file(os.path.join(UPSTREAM_DIR, INSTALLER_INFO_DIR, f"{it['version']}.json"), maven_url)
|
get_json_file(os.path.join(UPSTREAM_DIR, INSTALLER_INFO_DIR, f"{it['version']}.json"), maven_url)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user