mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Fix installing by file ID, allow using --file-id with slug
This commit is contained in:
parent
e29c3022b3
commit
efb434dadc
@ -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 {
|
||||
return modFileInfo{}, errors.New("mod not available for the configured Minecraft version(s) (use the acceptable-game-versions option to accept more) or loader")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user