Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions internal/api/qbit.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"mime"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -113,9 +114,18 @@ func (s *Server) handleQBitTransferInfo(w http.ResponseWriter, r *http.Request)
}

func (s *Server) handleQBitAdd(w http.ResponseWriter, r *http.Request) {
if err := r.ParseMultipartForm(8 << 20); err != nil { // 8 MB; torrent files are typically < 1 MB
http.Error(w, err.Error(), http.StatusBadRequest)
return
contentType := r.Header.Get("Content-Type")
mediaType, _, _ := mime.ParseMediaType(contentType)
if mediaType == "multipart/form-data" {
if err := r.ParseMultipartForm(8 << 20); err != nil { // 8 MB; torrent files are typically < 1 MB
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
} else {
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}

category := strings.TrimSpace(r.PostFormValue("category"))
Expand Down
4 changes: 4 additions & 0 deletions internal/compat/qbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type QBitTorrentInfo struct {
Priority int `json:"priority"`
Progress float64 `json:"progress"`
Ratio float64 `json:"ratio"`
RatioLimit float64 `json:"ratio_limit"`
SeedingTime int64 `json:"seeding_time"`
SavePath string `json:"save_path"`
Size int64 `json:"size"`
State string `json:"state"`
Expand Down Expand Up @@ -120,6 +122,8 @@ func ProjectQBitTorrent(job *store.Job) QBitTorrentInfo {
Priority: 0,
Progress: progress,
Ratio: 0,
RatioLimit: 0,
SeedingTime: 0,
SavePath: savePath,
Size: max(total, done),
State: state,
Expand Down