Skip to content

Commit

Permalink
fix: mcbbs modpack curseforge install should also no resolve duplicat…
Browse files Browse the repository at this point in the history
…ed files
  • Loading branch information
ci010 committed May 7, 2023
1 parent 97fc26e commit 2d1fd35
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion xmcl-runtime/lib/services/ModpackService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,24 @@ export class ModpackService extends AbstractService implements IModpackService {
const curseforgeFiles = manifest.files.map(f => f).filter((f): f is ModpackFileInfoCurseforge => !('type' in f) || f.type === 'curse' || 'hashes' in f)
const files = await curseforgeService.client.getFiles(curseforgeFiles.map(f => f.fileID))

const dict: Record<string, File> = {}
for (const file of files) {
if (dict[file.id]) {
this.warn(`Duplicated curseforge file return from curseforge API: ${file.id}`)
}
dict[file.id] = file
}

for (let i = 0; i < files.length; i++) {
const file = files[i]
const manifestFile = manifest.files[i]
if (!('fileID' in manifestFile)) {
continue
}
const file = dict[manifestFile.fileID]
if (!file) {
this.warn(`Skip file ${manifestFile.fileID} because it is not found in curseforge API`)
continue
}
const domain = file.fileName.endsWith('.jar') ? ResourceDomain.Mods : file.modules.some(f => f.name === 'META-INF') ? ResourceDomain.Mods : ResourceDomain.ResourcePacks
const sha1 = file.hashes.find(v => v.algo === HashAlgo.Sha1)?.value
infos.push({
Expand Down

0 comments on commit 2d1fd35

Please sign in to comment.