From efb434dadca0d917e6c165deb596c63a2a81a488 Mon Sep 17 00:00:00 2001 From: comp500 Date: Sat, 30 Apr 2022 21:02:00 +0100 Subject: [PATCH] Fix installing by file ID, allow using --file-id with slug --- curseforge/install.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/curseforge/install.go b/curseforge/install.go index 1f4bdf1..28601da 100644 --- a/curseforge/install.go +++ b/curseforge/install.go @@ -47,10 +47,11 @@ var installCmd = &cobra.Command{ var done bool var modID, fileID int // If mod/file IDs are provided in command line, use those - // TODO: use file id with slug if it exists? + if fileIDFlag != 0 { + fileID = fileIDFlag + } if addonIDFlag != 0 { modID = addonIDFlag - fileID = fileIDFlag done = true } if (len(args) == 0 || len(args[0]) == 0) && !done { @@ -334,12 +335,12 @@ func searchCurseforgeInternal(args []string, mcVersion string, packLoaderType in } func getLatestFile(modInfoData modInfo, mcVersion string, fileID int, packLoaderType int) (modFileInfo, error) { - anyFileObtained := false - // For snapshots, curseforge doesn't put them in GameVersionLatestFiles if fileID == 0 { var fileInfoData modFileInfo fileInfoObtained := false + anyFileObtained := false + // For snapshots, curseforge doesn't put them in GameVersionLatestFiles for _, v := range modInfoData.LatestFiles { anyFileObtained = true // Choose "newest" version by largest ID @@ -361,13 +362,10 @@ func getLatestFile(modInfoData modInfo, mcVersion string, fileID int, packLoader if fileInfoObtained { return fileInfoData, nil } - } - if !anyFileObtained { - return modFileInfo{}, fmt.Errorf("addon %d has no files", modInfoData.ID) - } - - if fileID == 0 { + if !anyFileObtained { + return modFileInfo{}, fmt.Errorf("addon %d has no files", modInfoData.ID) + } return modFileInfo{}, errors.New("mod not available for the configured Minecraft version(s) (use the acceptable-game-versions option to accept more) or loader") }