bugfix: upload possible again

This commit is contained in:
knoxfighter 2017-09-28 00:56:45 +02:00
parent 2eed86bec4
commit 3ee1842344
2 changed files with 6 additions and 33 deletions

View File

@ -9,6 +9,7 @@ import (
"archive/zip" "archive/zip"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
) )
type Mods struct { type Mods struct {
@ -164,14 +165,13 @@ func (mods *Mods) uploadMod(header *multipart.FileHeader) (error) {
} }
defer file.Close() defer file.Close()
var buff bytes.Buffer file_byte_array, err := ioutil.ReadAll(file)
file_length, err := buff.ReadFrom(file)
if err != nil { if err != nil {
log.Printf("Error occured while reading bytes.Buffer.ReadFrom: %s", err) log.Printf("error reading file: %s", err)
return err return err
} }
zip_reader, err := zip.NewReader(file, file_length) zip_reader, err := zip.NewReader(bytes.NewReader(file_byte_array), int64(len(file_byte_array)))
if err != nil { if err != nil {
log.Printf("Uploaded file could not put into zip.Reader: %s", err) log.Printf("Uploaded file could not put into zip.Reader: %s", err)
return err return err
@ -184,7 +184,7 @@ func (mods *Mods) uploadMod(header *multipart.FileHeader) (error) {
return err return err
} }
err = mods.createMod(mod_info.Name, header.Filename, file) err = mods.createMod(mod_info.Name, header.Filename, bytes.NewReader(file_byte_array))
if err != nil { if err != nil {
log.Printf("error on creating Mod: %s", err) log.Printf("error on creating Mod: %s", err)
return err return err

View File

@ -249,30 +249,3 @@ func (mod_pack *ModPack) loadModPack() error {
return nil return nil
} }
//func modPackToggleMod(mod_pack_name string, mod_name string) (ModPackList, error) {
// //var err error
// //var mod_pack_list ModPackList
// //
// //mod_pack := ModPack{
// // Name: mod_pack_name,
// //}
// //
// //temp_dir, err := mod_pack.create_temp_dir()
// //if err != nil {
// // log.Printf("error when creating temp_dir: %s", err)
// // return mod_pack_list, err
// //}
// //defer os.RemoveAll(temp_dir)
// //
// //var mods_list ModsList
// //err = mods_list.listInstalledMods(temp_dir)
// //if err != nil {
// // log.Printf("error on listing mods in temp_dir: %s", err)
// // return mod_pack_list, err
// //}
// //
// //log.Print(mods_list)
//
// return ModPackList{}, nil
//}