Fix filesize bug
Cette révision appartient à :
Parent
5866881eca
révision
590ebbf0d8
2 fichiers modifiés avec 9 ajouts et 4 suppressions
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/NyaaPantsu/nyaa/utils/upload"
|
||||
"github.com/NyaaPantsu/nyaa/utils/validator/torrent"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/NyaaPantsu/nyaa/utils/log"
|
||||
)
|
||||
|
||||
// UploadHandler : Main Controller for uploading a torrent
|
||||
|
@ -66,8 +67,8 @@ func UploadPostHandler(c *gin.Context) {
|
|||
|
||||
if !messages.HasErrors() {
|
||||
// add to db and redirect
|
||||
torrent, _ := torrents.Create(user, &uploadForm)
|
||||
|
||||
torrent, err := torrents.Create(user, &uploadForm)
|
||||
log.CheckErrorWithMessage(err, "ERROR_TORRENT_CREATED: Error while creating entry in db")
|
||||
url := "/view/" + strconv.FormatUint(uint64(torrent.ID), 10)
|
||||
c.Redirect(302, url+"?success")
|
||||
}
|
||||
|
|
|
@ -25,7 +25,11 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
UploaderID: user.ID}
|
||||
torrent.EncodeLanguages() // Convert languages array in language string
|
||||
torrent.ParseTrackers(uploadForm.Trackers)
|
||||
models.ORM.Create(&torrent)
|
||||
err := models.ORM.Create(&torrent).Error
|
||||
log.Infof("Torrent ID %d created!\n", torrent.ID)
|
||||
if err != nil {
|
||||
log.CheckErrorWithMessage(err, "ERROR_TORRENT_CREATE: Cannot create a torrent")
|
||||
}
|
||||
if config.Get().Search.EnableElasticSearch && models.ElasticSearchClient != nil {
|
||||
err := torrent.AddToESIndex(models.ElasticSearchClient)
|
||||
if err == nil {
|
||||
|
@ -39,7 +43,7 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
NewTorrentEvent(user, &torrent)
|
||||
if len(uploadForm.FileList) > 0 {
|
||||
for _, uploadedFile := range uploadForm.FileList {
|
||||
file := models.File{TorrentID: torrent.ID, Filesize: uploadForm.Filesize}
|
||||
file := models.File{TorrentID: torrent.ID, Filesize: uploadedFile.Filesize}
|
||||
err := file.SetPath(uploadedFile.Path)
|
||||
if err != nil {
|
||||
return &torrent, err
|
||||
|
|
Référencer dans un nouveau ticket