From b68bd9ead4d7bd00641e4fe0d0a256c3b34db7ee Mon Sep 17 00:00:00 2001 From: akuma06 Date: Sat, 10 Jun 2017 20:09:25 +0200 Subject: [PATCH] Fix required torrent name on upload --- service/api/api.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/service/api/api.go b/service/api/api.go index ff78a8c5..c5fb2ba6 100644 --- a/service/api/api.go +++ b/service/api/api.go @@ -221,6 +221,10 @@ func (r *TorrentRequest) ExtractEditInfo(req *http.Request) error { return err } + err = r.validateName() + if err != nil { + return err + } defer req.Body.Close() err = r.ExtractCategory(req) @@ -288,12 +292,8 @@ func (r *TorrentRequest) ExtractBasicValue(req *http.Request) error { r.Magnet = strings.TrimSpace(r.Magnet) // then actually check that we have everything we need - err := r.validateName() - if err != nil { - return err - } - err = r.validateDescription() + err := r.validateDescription() if err != nil { return err } @@ -328,6 +328,12 @@ func (r *TorrentRequest) ExtractInfo(req *http.Request) error { return err } + // We check name only here, reason: we can try to retrieve them from the torrent file + err = r.validateName() + if err != nil { + return err + } + // after data has been checked & extracted, write it to disk if len(config.Conf.Torrents.FileStorage) > 0 { err := writeTorrentToDisk(tfile, r.Infohash+".torrent", &r.Filepath)