Changelog 0.2.3

This commit is contained in:
Mukhtar Akere
2024-09-17 00:29:02 +01:00
parent 2ec0354881
commit 01981114cb
5 changed files with 71 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ type Service interface {
SubmitMagnet(torrent *Torrent) (*Torrent, error)
CheckStatus(torrent *Torrent) (*Torrent, error)
DownloadLink(torrent *Torrent) error
DeleteTorrent(torrent *Torrent)
IsAvailable(infohashes []string) map[string]bool
GetMountPath() string
GetDownloadUncached() bool
@@ -134,7 +135,7 @@ func ProcessQBitTorrent(d Service, magnet *common.Magnet, arr *Arr) (*Torrent, e
if !exists || !hash {
return debridTorrent, fmt.Errorf("torrent: %s is not cached", debridTorrent.Name)
} else {
logger.Printf("Torrent: %s is cached", debridTorrent.Name)
logger.Printf("Torrent: %s is cached(or downloading)", debridTorrent.Name)
}
}

View File

@@ -203,15 +203,28 @@ func (r *RealDebrid) CheckStatus(torrent *Torrent) (*Torrent, error) {
break
} else if status == "downloading" {
if !r.DownloadUncached {
// @TODO: Delete the torrent if it's not cached
go r.DeleteTorrent(torrent)
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
}
// Break out of the loop if the torrent is downloading.
// This is necessary to prevent infinite loop since we moved to sync downloading and async processing
break
}
}
return torrent, nil
}
func (r *RealDebrid) DeleteTorrent(torrent *Torrent) {
url := fmt.Sprintf("%s/torrents/delete/%s", r.Host, torrent.Id)
_, err := r.client.MakeRequest(http.MethodDelete, url, nil)
if err == nil {
r.logger.Printf("Torrent: %s deleted\n", torrent.Name)
} else {
r.logger.Printf("Error deleting torrent: %s", err)
}
}
func (r *RealDebrid) DownloadLink(torrent *Torrent) error {
return nil
}