mirror of
https://github.com/packwiz/packwiz.git
synced 2025-11-19 01:24:32 +01:00
- Fixed creation of duplicate index entries when importing from CurseForge (fixes #224) - Automatically remove duplicates in index - Fixed `packwiz serve` with a custom `--pack-root` argument (fixes #223) - Fixed `packwiz serve` with a custom index.toml location - Cleaned up internal serving code, added comments and better errors - Refactored path handling code - Improved refreshing/exporting performance - Factored out duplicated exporting logic - Replaced GetAllMods calls with cleaner LoadAllMods calls and made the former private - Improved variable names in update command - Improved handling of aliassed files - Changed CheckUpdate to take references to metadata - Removed the ability to use an absolute path to the index file (that probably didn't work anyway) - Behaviour change: order of entries in exported files may be random
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"golang.org/x/exp/slices"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/packwiz/packwiz/core"
|
||||
@@ -55,9 +54,6 @@ var exportCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: should index just expose indexPath itself, through a function?
|
||||
indexPath := filepath.Join(filepath.Dir(viper.GetString("pack-file")), filepath.FromSlash(pack.Index.File))
|
||||
|
||||
fmt.Println("Reading external files...")
|
||||
mods, err := index.LoadAllMods()
|
||||
if err != nil {
|
||||
@@ -113,15 +109,13 @@ var exportCmd = &cobra.Command{
|
||||
fmt.Printf("Warning for %s (%s): %v\n", dl.Mod.Name, dl.Mod.FileName, warning)
|
||||
}
|
||||
|
||||
pathForward, err := filepath.Rel(filepath.Dir(indexPath), dl.Mod.GetDestFilePath())
|
||||
path, err := index.RelIndexPath(dl.Mod.GetDestFilePath())
|
||||
if err != nil {
|
||||
fmt.Printf("Error resolving external file: %s\n", err.Error())
|
||||
// TODO: exit(1)?
|
||||
continue
|
||||
}
|
||||
|
||||
path := filepath.ToSlash(pathForward)
|
||||
|
||||
hashes := make(map[string]string)
|
||||
hashes["sha1"] = dl.Hashes["sha1"]
|
||||
hashes["sha512"] = dl.Hashes["sha512"]
|
||||
@@ -170,11 +164,11 @@ var exportCmd = &cobra.Command{
|
||||
fmt.Printf("%s (%s) added to manifest\n", dl.Mod.Name, dl.Mod.FileName)
|
||||
} else {
|
||||
if dl.Mod.Side == core.ClientSide {
|
||||
_ = cmdshared.AddToZip(dl, exp, "client-overrides", indexPath)
|
||||
_ = cmdshared.AddToZip(dl, exp, "client-overrides", &index)
|
||||
} else if dl.Mod.Side == core.ServerSide {
|
||||
_ = cmdshared.AddToZip(dl, exp, "server-overrides", indexPath)
|
||||
_ = cmdshared.AddToZip(dl, exp, "server-overrides", &index)
|
||||
} else {
|
||||
_ = cmdshared.AddToZip(dl, exp, "overrides", indexPath)
|
||||
_ = cmdshared.AddToZip(dl, exp, "overrides", &index)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,29 +227,7 @@ var exportCmd = &cobra.Command{
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, v := range index.Files {
|
||||
if !v.MetaFile {
|
||||
// Save all non-metadata files into the zip
|
||||
path, err := filepath.Rel(filepath.Dir(indexPath), index.GetFilePath(v))
|
||||
if err != nil {
|
||||
fmt.Printf("Error resolving file: %s\n", err.Error())
|
||||
// TODO: exit(1)?
|
||||
continue
|
||||
}
|
||||
file, err := exp.Create(filepath.ToSlash(filepath.Join("overrides", path)))
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating file: %s\n", err.Error())
|
||||
// TODO: exit(1)?
|
||||
continue
|
||||
}
|
||||
err = index.SaveFile(v, file)
|
||||
if err != nil {
|
||||
fmt.Printf("Error copying file: %s\n", err.Error())
|
||||
// TODO: exit(1)?
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
cmdshared.AddNonMetafileOverrides(&index, exp)
|
||||
|
||||
err = exp.Close()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user