Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

applied akuma dup fix

Cette révision appartient à :
ayame-git 2017-05-11 06:25:41 +03:00
Parent 7e3d116808
révision 42c79c2794
2 fichiers modifiés avec 25 ajouts et 41 suppressions

Voir le fichier

@ -133,47 +133,43 @@ func ApiUploadHandler(w http.ResponseWriter, r *http.Request) {
upload.Category, _ = strconv.Atoi(r.FormValue("category"))
upload.SubCategory, _ = strconv.Atoi(r.FormValue("sub_category"))
upload.Description = r.FormValue("description")
<<<<<<< HEAD
var err error
var code int
=======
var err error
var code int
>>>>>>> 5a32c00f503906080d518ceea69897f251933ac1
filesize, err, code = upload.ValidateMultipartUpload(r)
if err != nil {
http.Error(w, err.Error(), code)
return
}
}
var sameTorrents int
db.ORM.Model(&model.Torrent{}).Where("torrent_hash = ?", upload.Hash).Count(&sameTorrents)
torrent := model.Torrent{
Name: upload.Name,
Category: upload.Category,
SubCategory: upload.SubCategory,
Status: 1,
Hash: upload.Hash,
Date: time.Now(),
Filesize: filesize,
Description: upload.Description,
UploaderID: user.ID,
Uploader: &user,
}
<<<<<<< HEAD
db.ORM.Create(&torrent)
/*if err != nil {
=======
/*db.ORM.Create(&torrent)
if err != nil {
>>>>>>> 5a32c00f503906080d518ceea69897f251933ac1
util.SendError(w, err, 500)
if sameTorrents == 0 {
torrent := model.Torrent{
Name: upload.Name,
Category: upload.Category,
SubCategory: upload.SubCategory,
Status: 1,
Hash: upload.Hash,
Date: time.Now(),
Filesize: filesize,
Description: upload.Description,
UploaderID: user.ID,
Uploader: &user,
}
db.ORM.Create(&torrent)
/*if err != nil {
util.SendError(w, err, 500)
return
}*/
fmt.Printf("%+v\n", torrent)
} else {
http.Error(w, "torrent already exists", http.StatusBadRequest)
return
}*/
fmt.Printf("%+v\n", torrent)
}
}
func ApiUpdateHandler(w http.ResponseWriter, r *http.Request) {

Voir le fichier

@ -12,10 +12,7 @@ import (
"github.com/ewhal/nyaa/model"
"github.com/ewhal/nyaa/service"
<<<<<<< HEAD
"github.com/ewhal/nyaa/service/upload"
=======
>>>>>>> 5a32c00f503906080d518ceea69897f251933ac1
"github.com/ewhal/nyaa/util/metainfo"
"github.com/zeebo/bencode"
)
@ -151,19 +148,10 @@ func (r *TorrentRequest) ValidateMultipartUpload(req *http.Request) (int64, erro
if torrent.IsPrivate() {
return 0, errors.New("private torrents not allowed"), http.StatusBadRequest
}
<<<<<<< HEAD
trackers := torrent.GetAllAnnounceURLS()
if !uploadService.CheckTrackers(trackers) {
return 0, errors.New("tracker(s) not allowed"), http.StatusBadRequest
}
=======
//import cycle
/*trackers := torrent.GetAllAnnounceURLS()
if !router.CheckTrackers(trackers) {
return 0, errors.New("tracker(s) not allowed"), http.StatusBadRequest
}*/
>>>>>>> 5a32c00f503906080d518ceea69897f251933ac1
if r.Name == "" {
r.Name = torrent.TorrentName()
}