bugfix: mod-upload broke mods

This commit is contained in:
knoxfighter 2017-09-30 02:52:40 +02:00
parent e1b2a017d4
commit caba55241b
3 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"path/filepath"
)
type Mods struct {
@ -164,7 +165,9 @@ func (mods *Mods) downloadMod(url string, filename string, mod_id string) (error
func (mods *Mods) uploadMod(header *multipart.FileHeader) (error) {
var err error
if header.Header.Get("Content-Type") != "application/zip" {
log.Printf("filename of the uploaded file: %s", header.Filename)
if filepath.Ext(header.Filename) != ".zip" {
log.Print("The uploaded file wasn't a zip-file -> ignore it")
return nil //simply do nothing xD
}

View File

@ -109,7 +109,7 @@ func factorioLogin(username string, password string) (string, error, int) {
if resp.StatusCode != http.StatusOK {
log.Println("error Statuscode not 200")
return body_string, errors.New("Statuscode not 200"), resp.StatusCode
return body_string, errors.New(body_string), resp.StatusCode
}
var success_response []string

View File

@ -13,6 +13,9 @@ class ModUpload extends React.Component {
allowedFileExtensions: ['zip'],
browseLabel: "Select Mods...",
browseIcon: '<i class="fa fa-upload text-muted" style="color: white;"></i>&nbsp;',
slugCallback: function(filename) {
return filename;
},
}).on('filebatchuploadsuccess fileuploaded', this.props.uploadModSuccessHandler);
}