mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-24 05:17:24 +02:00
bugfix: upload possible again
This commit is contained in:
parent
2eed86bec4
commit
3ee1842344
@ -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
|
||||
|
@ -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
|
||||
//}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user