mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Batch metadata retrieval in CF detection (fixes #151)
This commit is contained in:
parent
4c68c7240f
commit
f79de590d9
@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/aviddiviner/go-murmur"
|
"github.com/aviddiviner/go-murmur"
|
||||||
"github.com/packwiz/packwiz/core"
|
"github.com/packwiz/packwiz/core"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -46,7 +45,7 @@ var detectCmd = &cobra.Command{
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fmt.Println("Hashing " + path)
|
fmt.Println("Hashing " + path)
|
||||||
bytes, err := ioutil.ReadFile(path)
|
bytes, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -80,15 +79,21 @@ var detectCmd = &cobra.Command{
|
|||||||
fmt.Printf("%s (%d)\n", modPaths[v], v)
|
fmt.Printf("%s (%d)\n", modPaths[v], v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Installing...")
|
|
||||||
for _, v := range res.ExactMatches {
|
fmt.Println("Retrieving metadata...")
|
||||||
modInfoData, err := cfDefaultClient.getModInfo(v.ID)
|
ids := make([]uint32, len(res.ExactMatches))
|
||||||
|
for i, v := range res.ExactMatches {
|
||||||
|
ids[i] = v.ID
|
||||||
|
}
|
||||||
|
modInfos, err := cfDefaultClient.getModInfoMultiple(ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Printf("Failed to retrieve metadata: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createModFile(modInfoData, v.File, &index, false)
|
fmt.Println("Creating metadata files...")
|
||||||
|
for i, v := range res.ExactMatches {
|
||||||
|
err = createModFile(modInfos[i], v.File, &index, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -103,7 +108,7 @@ var detectCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Installation done")
|
fmt.Println("Detection complete!")
|
||||||
|
|
||||||
err = index.Refresh()
|
err = index.Refresh()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user