Skip to content

Commit f4df375

Browse files
committed
fix: diagnose libraries for install profile
1 parent d5babfd commit f4df375

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

packages/installer/diagnose.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface Issue {
3737
}
3838

3939
export type MinecraftIssues = LibraryIssue | MinecraftJarIssue | VersionJsonIssue | AssetIssue | AssetIndexIssue;
40-
export type InstallIssues = Issue;
40+
export type InstallIssues = ProcessorIssue | LibraryIssue;
4141

4242
export interface ProcessorIssue extends Issue {
4343
role: "processor";
@@ -98,7 +98,7 @@ export interface MinecraftIssueReport {
9898
export interface InstallProfileIssueReport {
9999
minecraftLocation: MinecraftFolder;
100100
installProfile: InstallProfile;
101-
issues: ProcessorIssue[];
101+
issues: InstallIssues[];
102102
}
103103

104104
async function diagnoseSingleFile(role: Issue["role"], file: string, expectedChecksum: string, hint: string) {
@@ -240,17 +240,24 @@ export function diagnoseInstallTask(installProfile: InstallProfile, minecraftLoc
240240
installProfile,
241241
issues: [],
242242
};
243-
let processors: Processor[];
244-
try {
245-
processors = resolveProcessors("client", installProfile, mc);
246-
} catch (e) {
247-
return report;
248-
}
243+
let issues = report.issues;
244+
let processors: Processor[] = resolveProcessors("client", installProfile, mc);
249245

250246
let done = 0;
251-
let total = processors.length;
252-
let issues = report.issues;
247+
let total = installProfile.libraries.length + processors.length;
253248
c.update(done, total);
249+
250+
await Promise.all(Version.resolveLibraries(installProfile.libraries).map(async (lib) => {
251+
let libPath = mc.getLibraryByPath(lib.download.path);
252+
let issue: LibraryIssue | undefined = await diagnoseSingleFile("library", libPath, lib.download.sha1,
253+
"Problem on install_profile! Please consider to use Installer.installByProfile to fix.");
254+
if (issue) {
255+
issue.library = lib;
256+
issues.push(issue);
257+
}
258+
c.update(done += 1, total, lib.name);
259+
}));
260+
254261
for (let proc of processors) {
255262
if (proc.outputs) {
256263
for (let file in proc.outputs) {

packages/installer/minecraft.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ export function installAssetsTask(version: ResolvedVersion, options: AssetsOptio
337337
interface AssetIndex {
338338
objects: {
339339
[key: string]: {
340-
hash: string,
341-
size: number,
340+
hash: string;
341+
size: number;
342342
};
343343
};
344344
}
@@ -353,7 +353,7 @@ export function installAssetsTask(version: ResolvedVersion, options: AssetsOptio
353353

354354
return version;
355355
}
356-
return task("installAssets", installAssets, { version: version.id })
356+
return task("installAssets", installAssets, { version: version.id });
357357
}
358358

359359
/**
@@ -553,7 +553,7 @@ export function installByProfileTask(installProfile: InstallProfile, minecraft:
553553
try {
554554
await spawnProcess(java, cmd);
555555
} catch (e) {
556-
throw new Error(`Fail on execute processor ${proc.jar}: ${JSON.stringify(cmd)}`)
556+
throw new Error(`Fail on execute processor ${proc.jar}: ${JSON.stringify(cmd)}`);
557557
}
558558
let failed = false;
559559
if (proc.outputs) {

0 commit comments

Comments
 (0)