From 90b5ac79bc0bc3c54e2dc448cefa1d51fe5ce4de Mon Sep 17 00:00:00 2001 From: Kallum Jones Date: Sun, 14 Aug 2022 13:58:25 +0100 Subject: [PATCH] Fix out of date dependencies being downloaded (fixes #1) --- src/mods/sources/modrinth_source.ts | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/mods/sources/modrinth_source.ts b/src/mods/sources/modrinth_source.ts index 1cfb60d..ffeda12 100644 --- a/src/mods/sources/modrinth_source.ts +++ b/src/mods/sources/modrinth_source.ts @@ -144,7 +144,8 @@ export default class ModrinthSource implements ModSource { if (projectId != undefined) { return this.getLatestVersion(projectId, mcVersion) } else if (versionId != undefined) { - return this.getVersionFromVersionId(versionId, projectId, mcVersion) + const projectId = await this.getProjectFromVersionId(versionId); + return this.getLatestVersion(projectId, mcVersion); } else { throw new Error("Dependency found with no project or version id") } @@ -186,32 +187,11 @@ export default class ModrinthSource implements ModSource { * ] * } * @param versionId the version id to transform into an object - * @param projectId the project id of this version - * @param mcVersion the Minecraft version we are downloading for * @return the Version object */ - async getVersionFromVersionId(versionId: string, projectId: string | undefined, mcVersion: string): Promise { + async getProjectFromVersionId(versionId: string): Promise { const response = await axios.get(format(ModrinthSource.SINGLE_VERSION_URL, versionId)); const latestVersion = await response.data; - - const latestFile = latestVersion.files[0]; - - const dependencies = []; - if (!Util.isArrayEmpty(latestVersion.dependencies)) { - for (let dependency of latestVersion.dependencies) { - dependencies.push(await this.getDependency(projectId, dependency.version_id, mcVersion)) - } - } - - const checksum = latestFile.hashes.sha1; - - return { - modId: latestVersion.project_id, - versionNumber: latestVersion.version_number, - fileName: latestFile.filename, - url: latestFile.url, - dependencies: dependencies, - checksum: checksum - }; + return latestVersion.project_id; } } \ No newline at end of file