Change the type of torrent's id from int to string

This commit is contained in:
Grégoire Delattre 2018-12-16 10:31:16 +01:00
parent dcca50671c
commit 0be12b2fa1
3 changed files with 6 additions and 10 deletions

View File

@ -56,7 +56,7 @@ func setupRoutes(env *web.Env) {
// Torrents routes // Torrents routes
env.Handle("/torrents", torrents.DownloadHandler).WithRole(users.UserRole).Methods("POST") env.Handle("/torrents", torrents.DownloadHandler).WithRole(users.UserRole).Methods("POST")
env.Handle("/torrents", torrents.ListHandler).WithRole(users.UserRole).Methods("GET") env.Handle("/torrents", torrents.ListHandler).WithRole(users.UserRole).Methods("GET")
env.Handle("/torrents/{id:[0-9]+}", torrents.RemoveHandler).WithRole(users.UserRole).Methods("DELETE") env.Handle("/torrents/{id}", torrents.RemoveHandler).WithRole(users.UserRole).Methods("DELETE")
env.Handle("/torrents/search/{type}/{search}", torrents.SearchHandler).WithRole(users.UserRole).Methods("GET") env.Handle("/torrents/search/{type}/{search}", torrents.SearchHandler).WithRole(users.UserRole).Methods("GET")
// Route to refresh all movies and shows // Route to refresh all movies and shows

View File

@ -5,14 +5,13 @@ import (
"errors" "errors"
"net/http" "net/http"
"sort" "sort"
"strconv"
"github.com/gorilla/mux"
"github.com/odwrtw/polochon/lib"
"github.com/sirupsen/logrus"
"git.quimbo.fr/odwrtw/canape/backend/auth" "git.quimbo.fr/odwrtw/canape/backend/auth"
"git.quimbo.fr/odwrtw/canape/backend/users" "git.quimbo.fr/odwrtw/canape/backend/users"
"git.quimbo.fr/odwrtw/canape/backend/web" "git.quimbo.fr/odwrtw/canape/backend/web"
"github.com/gorilla/mux"
polochon "github.com/odwrtw/polochon/lib"
"github.com/sirupsen/logrus"
) )
// DownloadHandler downloads a movie via polochon // DownloadHandler downloads a movie via polochon
@ -79,10 +78,7 @@ func RemoveHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error {
// Get the torrent ID from the URL // Get the torrent ID from the URL
vars := mux.Vars(r) vars := mux.Vars(r)
torrentID, err := strconv.Atoi(vars["id"]) torrentID := vars["id"]
if err != nil {
return env.RenderError(w, errors.New("invalid argument"))
}
client, err := user.NewPapiClient() client, err := user.NewPapiClient()
if err != nil { if err != nil {

View File

@ -111,7 +111,7 @@ class Torrent extends React.PureComponent {
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
} }
handleClick() { handleClick() {
this.props.removeTorrent(this.props.data.getIn(["additional_infos", "id"])); this.props.removeTorrent(this.props.data.get("id"));
} }
render() { render() {
const done = this.props.data.get("is_finished"); const done = this.props.data.get("is_finished");