v1.0.15.1 — fix server re-extract of launcher zips; correct Forge launch command (-cp per version.json)

This commit is contained in:
SashegDev
2026-08-13 09:33:44 +00:00
parent b6dccd67ac
commit f857d91e4d
4 changed files with 148 additions and 83 deletions
+38 -27
View File
@@ -1377,6 +1377,37 @@ def generate_launcher_builds_meta():
logger.warning(f"Failed to save meta.json: {e}")
def generate_version_meta(version_path: Path, version: str) -> dict:
"""Generate and cache meta.json for an extracted version directory."""
files = []
for file_path in version_path.rglob("*"):
if file_path.is_file() and file_path.name != "meta.json":
rel_path = str(file_path.relative_to(version_path))
stat = file_path.stat()
file_hash = calculate_file_hash(file_path)
files.append({
"path": rel_path,
"size": stat.st_size,
"hash": f"sha256:{file_hash}"
})
meta = {
"version": version,
"type": "new",
"release_date": datetime.utcnow().isoformat(),
"files": files
}
try:
meta_path = version_path / "meta.json"
with open(meta_path, 'w', encoding='utf-8') as f:
json.dump(meta, f, indent=2)
except Exception as e:
logger.warning(f"Failed to save launcher meta for {version}: {e}")
return meta
def scan_launcher_version(version: str) -> Optional[dict]:
"""Scan a launcher version directory and return meta"""
# First check if meta exists in builds/ directly (for new format)
@@ -1407,33 +1438,7 @@ def scan_launcher_version(version: str) -> Optional[dict]:
pass
# Generate meta
files = []
for file_path in version_path.rglob("*"):
if file_path.is_file() and file_path.name != "meta.json":
rel_path = str(file_path.relative_to(version_path))
stat = file_path.stat()
file_hash = calculate_file_hash(file_path)
files.append({
"path": rel_path,
"size": stat.st_size,
"hash": f"sha256:{file_hash}"
})
meta = {
"version": version,
"type": "new",
"release_date": datetime.utcnow().isoformat(),
"files": files
}
# Save meta
try:
with open(meta_path, 'w', encoding='utf-8') as f:
json.dump(meta, f, indent=2)
except Exception as e:
logger.warning(f"Failed to save launcher meta for {version}: {e}")
return meta
return generate_version_meta(version_path, version)
def parse_version_key(v: str) -> tuple:
@@ -1492,6 +1497,12 @@ def extract_new_format_versions():
# Extract all files
zf.extractall(extract_dir)
# Generate meta.json cache for the extracted version. Without this the
# "already extracted" check above always fails: scan_launcher_version()
# short-circuits on BUILDS_DIR/meta.json for the latest version and never
# writes versions/<v>/meta.json, so every scan would re-extract the zip.
generate_version_meta(extract_dir, version)
logger.info(f"Extracted {zip_file.name} successfully")
except Exception as e:
logger.error(f"Failed to extract {zip_file.name}: {e}")