fixed overrides extraction

This commit is contained in:
= 2024-11-25 14:55:04 -07:00
parent 2b372423eb
commit 8208434b8f

View File

@ -507,12 +507,24 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
if prefix == "overrides" || prefix == "client-overrides" { if prefix == "overrides" || prefix == "client-overrides" {
path := strings.SplitN(entry.Name, "/", 2)[1] path := strings.SplitN(entry.Name, "/", 2)[1]
if entry.IsDir() { if entry.IsDir() {
fmt.Printf("creating directory %s\n", filepath.Join(InstancePath, path))
if _, err := os.Stat(filepath.Join(InstancePath, path)); err != nil { if _, err := os.Stat(filepath.Join(InstancePath, path)); err != nil {
os.MkdirAll(filepath.Join(InstancePath, path), 0755) os.MkdirAll(filepath.Join(InstancePath, path), 0755)
} }
} else { } else {
zf, _ := entry.Open() zf, _ := entry.Open()
defer zf.Close() defer zf.Close()
fileDir := ""
tokens := strings.Split(path, "/")
for ind, token := range tokens {
if ind != len(tokens)-1 {
fileDir = filepath.Join(fileDir, token)
}
}
fmt.Printf("creating directory %s\n", filepath.Join(InstancePath, fileDir))
if _, err := os.Stat(filepath.Join(InstancePath, fileDir)); err != nil {
os.MkdirAll(filepath.Join(InstancePath, fileDir), 0755)
}
file, _ := os.OpenFile(filepath.Join(InstancePath, path), os.O_CREATE|os.O_RDWR, 0755) file, _ := os.OpenFile(filepath.Join(InstancePath, path), os.O_CREATE|os.O_RDWR, 0755)
defer file.Close() defer file.Close()
io.Copy(file, zf) io.Copy(file, zf)