fix: always download Quilt Jars for timestamps

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-05-01 16:22:33 +02:00
parent f7020ba176
commit bd1326daf2
No known key found for this signature in database
GPG Key ID: E13DFD4B47127951

View File

@ -65,25 +65,17 @@ def get_binary_file(path, url):
def compute_jar_file(path, url): def compute_jar_file(path, url):
# These two approaches should result in the same metadata, except for the timestamp which might be a few minutes # NOTE: Quilt Meta does not make any guarantees about Last-Modified.
# off for the fallback method # Always download the JAR file instead
try: jar_path = path + ".jar"
# Let's not download a Jar file if we don't need to. get_binary_file(jar_path, url)
headers = head_file(url) tstamp = datetime.fromtimestamp(0)
tstamp = datetime.strptime(headers["Last-Modified"], DATETIME_FORMAT_HTTP) with zipfile.ZipFile(jar_path) as jar:
except requests.HTTPError: allinfo = jar.infolist()
# Just in case something changes in the future for info in allinfo:
print(f"Falling back to downloading jar for {url}") tstamp_new = datetime(*info.date_time)
if tstamp_new > tstamp:
jar_path = path + ".jar" tstamp = tstamp_new
get_binary_file(jar_path, url)
tstamp = datetime.fromtimestamp(0)
with zipfile.ZipFile(jar_path) as jar:
allinfo = jar.infolist()
for info in allinfo:
tstamp_new = datetime(*info.date_time)
if tstamp_new > tstamp:
tstamp = tstamp_new
data = FabricJarInfo(release_time=tstamp) data = FabricJarInfo(release_time=tstamp)
data.write(path + ".json") data.write(path + ".json")