Make sure torrents get deleted on failed
This commit is contained in:
@@ -163,6 +163,9 @@ func ProcessTorrent(d *DebridService, magnet *common.Magnet, a *arr.Arr, isSymli
|
|||||||
|
|
||||||
dbt, err := db.SubmitMagnet(debridTorrent)
|
dbt, err := db.SubmitMagnet(debridTorrent)
|
||||||
if err != nil || dbt.Id == "" {
|
if err != nil || dbt.Id == "" {
|
||||||
|
if dbt != nil {
|
||||||
|
dbt.Delete()
|
||||||
|
}
|
||||||
logger.Printf("Error submitting magnet: %s", err)
|
logger.Printf("Error submitting magnet: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ func (s *Server) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if contentType == "multipart/form-data" {
|
if contentType == "multipart/form-data" {
|
||||||
files := r.MultipartForm.File["torrents"]
|
files := r.MultipartForm.File["torrents"]
|
||||||
|
if len(files) == 0 {
|
||||||
|
s.logger.Printf("No files provided\n")
|
||||||
|
http.Error(w, "No files provided", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, fileHeader := range files {
|
for _, fileHeader := range files {
|
||||||
if err := s.qbit.AddTorrent(ctx, fileHeader, category); err != nil {
|
if err := s.qbit.AddTorrent(ctx, fileHeader, category); err != nil {
|
||||||
s.logger.Printf("Error adding torrent: %v\n", err)
|
s.logger.Printf("Error adding torrent: %v\n", err)
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ func (q *QBit) ProcessFiles(torrent *Torrent, debridTorrent *debrid.Torrent, arr
|
|||||||
dbT, err := debridTorrent.Debrid.CheckStatus(debridTorrent, isSymlink)
|
dbT, err := debridTorrent.Debrid.CheckStatus(debridTorrent, isSymlink)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.logger.Printf("Error checking status: %v", err)
|
q.logger.Printf("Error checking status: %v", err)
|
||||||
|
go debridTorrent.Delete()
|
||||||
q.MarkAsFailed(torrent)
|
q.MarkAsFailed(torrent)
|
||||||
_ = arr.Refresh()
|
_ = arr.Refresh()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user