From 3ee1842344e26b0ff66df339eaf319db85a6bd5e Mon Sep 17 00:00:00 2001 From: knoxfighter Date: Thu, 28 Sep 2017 00:56:45 +0200 Subject: [PATCH] bugfix: upload possible again --- src/mod_Mods.go | 10 +++++----- src/mod_modpacks.go | 29 +---------------------------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/mod_Mods.go b/src/mod_Mods.go index 6e58cb4..db957ff 100644 --- a/src/mod_Mods.go +++ b/src/mod_Mods.go @@ -9,6 +9,7 @@ import ( "archive/zip" "errors" "fmt" + "io/ioutil" ) type Mods struct { @@ -164,14 +165,13 @@ func (mods *Mods) uploadMod(header *multipart.FileHeader) (error) { } defer file.Close() - var buff bytes.Buffer - file_length, err := buff.ReadFrom(file) + file_byte_array, err := ioutil.ReadAll(file) if err != nil { - log.Printf("Error occured while reading bytes.Buffer.ReadFrom: %s", err) + log.Printf("error reading file: %s", 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 { log.Printf("Uploaded file could not put into zip.Reader: %s", err) return err @@ -184,7 +184,7 @@ func (mods *Mods) uploadMod(header *multipart.FileHeader) (error) { 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 { log.Printf("error on creating Mod: %s", err) return err diff --git a/src/mod_modpacks.go b/src/mod_modpacks.go index 108aa5e..ebff655 100644 --- a/src/mod_modpacks.go +++ b/src/mod_modpacks.go @@ -248,31 +248,4 @@ func (mod_pack *ModPack) loadModPack() error { } 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 -//} +} \ No newline at end of file