mirror of
https://github.com/packwiz/packwiz.git
synced 2025-11-19 01:24:32 +01:00
WIP caching system for Modrinth/CurseForge pack export
This commit is contained in:
11
core/mod.go
11
core/mod.go
@@ -27,11 +27,18 @@ type Mod struct {
|
||||
Option *ModOption `toml:"option,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
modeURL string = "url"
|
||||
modeCF string = "metadata:curseforge"
|
||||
)
|
||||
|
||||
// ModDownload specifies how to download the mod file
|
||||
type ModDownload struct {
|
||||
URL string `toml:"url"`
|
||||
URL string `toml:"url,omitempty"`
|
||||
HashFormat string `toml:"hash-format"`
|
||||
Hash string `toml:"hash"`
|
||||
// Mode defaults to modeURL (i.e. use URL)
|
||||
Mode string `toml:"mode"`
|
||||
}
|
||||
|
||||
// ModOption specifies optional metadata for this mod file
|
||||
@@ -130,6 +137,7 @@ func (m Mod) GetDestFilePath() string {
|
||||
|
||||
// DownloadFile attempts to resolve and download the file
|
||||
func (m Mod) DownloadFile(dest io.Writer) error {
|
||||
// TODO: check mode
|
||||
resp, err := http.Get(m.Download.URL)
|
||||
// TODO: content type, user-agent?
|
||||
if err != nil {
|
||||
@@ -176,6 +184,7 @@ func (m Mod) GetHashes(hashes []string) (map[string]string, error) {
|
||||
|
||||
// Retrieve the remaining hashes
|
||||
if len(hashes) > 0 {
|
||||
// TODO: check mode
|
||||
resp, err := http.Get(m.Download.URL)
|
||||
// TODO: content type, user-agent?
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user