add set torrent, for set title,poster,data

This commit is contained in:
YouROK
2021-03-11 14:47:23 +03:00
parent c8b01bec30
commit 542946b65a
2 changed files with 34 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)
//Action: add, get, rem, list, drop
//Action: add, get, set, rem, list, drop
type torrReqJS struct {
requestI
Link string `json:"link,omitempty"`
@@ -41,6 +41,10 @@ func torrents(c *gin.Context) {
{
getTorrent(req, c)
}
case "set":
{
setTorrent(req, c)
}
case "rem":
{
remTorrent(req, c)
@@ -53,6 +57,7 @@ func torrents(c *gin.Context) {
{
dropTorrent(req, c)
}
}
}
@@ -107,6 +112,15 @@ func getTorrent(req torrReqJS, c *gin.Context) {
}
}
func setTorrent(req torrReqJS, c *gin.Context) {
if req.Hash == "" {
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))
return
}
torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Data)
c.Status(200)
}
func remTorrent(req torrReqJS, c *gin.Context) {
if req.Hash == "" {
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))