Change backend request code to use new CurseForge API (WIP)

See the packwiz Discord for more information, as the changes with the new API Terms and Conditions have some implications for packwiz.
This commit isn't fully functional yet; I have more changes to make.
This commit is contained in:
comp500
2022-05-07 18:18:57 +01:00
parent 9ace015690
commit 0c5ff0b7bb
5 changed files with 173 additions and 181 deletions

View File

@@ -176,11 +176,6 @@ func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index, opt
return err
}
u, err := core.ReencodeURL(fileInfo.DownloadURL)
if err != nil {
return err
}
hash, hashFormat := fileInfo.getBestHash()
var optional *core.ModOption
@@ -196,7 +191,6 @@ func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index, opt
FileName: fileInfo.FileName,
Side: core.UniversalSide,
Download: core.ModDownload{
URL: u,
HashFormat: hashFormat,
Hash: hash,
},
@@ -335,7 +329,7 @@ func (u cfUpdater) CheckUpdate(mods []core.Mod, mcVersion string, pack core.Pack
modIDs[i] = project.ProjectID
}
modInfosUnsorted, err := getModInfoMultiple(modIDs)
modInfosUnsorted, err := cfDefaultClient.getModInfoMultiple(modIDs)
if err != nil {
return nil, err
}
@@ -420,22 +414,16 @@ func (u cfUpdater) DoUpdate(mods []*core.Mod, cachedState []interface{}) error {
fileInfoData := modState.fileInfo
if !modState.hasFileInfo {
var err error
fileInfoData, err = getFileInfo(modState.ID, modState.fileID)
fileInfoData, err = cfDefaultClient.getFileInfo(modState.ID, modState.fileID)
if err != nil {
return err
}
}
u, err := core.ReencodeURL(fileInfoData.DownloadURL)
if err != nil {
return err
}
v.FileName = fileInfoData.FileName
v.Name = modState.Name
hash, hashFormat := fileInfoData.getBestHash()
v.Download = core.ModDownload{
URL: u,
HashFormat: hashFormat,
Hash: hash,
}