mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 05:28:22 -05:00
Fix out of date dependencies being downloaded (fixes #1)
This commit is contained in:
parent
066a63f913
commit
90b5ac79bc
@ -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<Version> {
|
||||
async getProjectFromVersionId(versionId: string): Promise<string> {
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user