Skip to content

Commit

Permalink
perf(install): perform better fabric install
Browse files Browse the repository at this point in the history
Fixed #140
  • Loading branch information
Andy-K-Sparklight committed Jul 15, 2022
1 parent b8889aa commit 1736441
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 389 deletions.
2 changes: 1 addition & 1 deletion src/modules/commons/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const FORGE_VERSIONS_MANIFEST =
"https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json";

export const FABRIC_META_ROOT = "https://meta.fabricmc.net/v2";

export const QUILT_META_ROOT = "https://meta.quiltmc.org/v3";
// MD5 of the following text (excluding quotes): "The developer of Alicorn Launcher is really a cute filly!"
export const CODE_32_SPECIAL = "61096da20861084f1e6a442d939717a8";

Expand Down
181 changes: 0 additions & 181 deletions src/modules/pff/get/FabricGet.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ import { MinecraftContainer } from "../../container/MinecraftContainer";
import { xgot } from "../../download/GotWrapper";
import { downloadProfile } from "./MojangCore";

const QUILT_ROOT = "https://meta.quiltmc.org/v3/versions/loader/";

function genQuiltName(mcv: string, ld: string): string {
return `quilt-loader-${ld}-${mcv}`;
const API_SUBFOLDER = "/versions/loader/";
function genFabricLikeName(type: string, mcv: string, ld: string): string {
return `${type}-${ld}-${mcv}`;
}

export async function getQuiltProfile(
export async function getFabricLikeProfile(
root: string,
type: string,
mcv: string,
c: MinecraftContainer
): Promise<boolean> {
try {
const loaders = await xgot(QUILT_ROOT + mcv);
const loaders = await xgot(root + API_SUBFOLDER + mcv);
const loaderName = (loaders as Array<{ loader: { version: string } }>)[0]
.loader.version;
const ver = genQuiltName(mcv, loaderName);
const ver = genFabricLikeName(type, mcv, loaderName);
await downloadProfile(
QUILT_ROOT + mcv + "/" + loaderName + "/profile/json",
root + API_SUBFOLDER + mcv + "/" + loaderName + "/profile/json",
c,
ver
);
Expand Down
109 changes: 0 additions & 109 deletions src/modules/pff/install/FabricInstall.ts

This file was deleted.

28 changes: 6 additions & 22 deletions src/modules/pff/modpack/InstallModpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@ import path from "path";
import { tr } from "../../../renderer/Translator";
import { basicHash } from "../../commons/BasicHash";
import { Pair } from "../../commons/Collections";
import { FABRIC_META_ROOT } from "../../commons/Constants";
import { isFileExist } from "../../commons/FileUtil";
import { isNull, safeGet } from "../../commons/Null";
import { safeGet } from "../../commons/Null";
import { MinecraftContainer } from "../../container/MinecraftContainer";
import { addDoing } from "../../download/DownloadWrapper";
import { getDefaultJavaHome, getJavaRunnable } from "../../java/JavaInfo";
import { ProfileType } from "../../profile/WhatProfile";
import {
getFabricInstaller,
getLatestFabricInstallerAndLoader,
removeFabricInstaller,
} from "../get/FabricGet";
import { getFabricLikeProfile } from "../get/FabricLikeGet";
import {
generateForgeInstallerName,
getForgeInstaller,
getMojangByForge,
removeForgeInstaller,
} from "../get/ForgeGet";
import { downloadProfile, getProfileURLById } from "../get/MojangCore";
import { performFabricInstall } from "../install/FabricInstall";
import { performForgeInstall } from "../install/ForgeInstall";
import { fetchSelectedMod, setPffFlag } from "../virtual/PffWrapper";
import {
Expand Down Expand Up @@ -184,31 +180,19 @@ export async function deployModLoader(
}
case ProfileType.FABRIC:
default: {
const u = (await getLatestFabricInstallerAndLoader()).getFirstValue();
if (isNull(u)) {
throw "Could not fetch installer: No such installer!";
}
if (!(await getFabricInstaller(u, container))) {
await removeFabricInstaller(u, container);
throw "Failed to fetch installer!";
}
const jr = await getJavaRunnable(getDefaultJavaHome());
await Promise.allSettled(
mcVersions.map((mcVersion) => {
return (async () => {
if (
!(await performFabricInstall(
jr,
u,
version,
!(await getFabricLikeProfile(
FABRIC_META_ROOT,
"fabric-loader",
mcVersion,
container
))
) {
await removeFabricInstaller(u, container);
throw "Could not perform install!";
}
await removeFabricInstaller(u, container);
})();
})
);
Expand Down
Loading

0 comments on commit 1736441

Please sign in to comment.