Fix arr download_uncached settings
This commit is contained in:
@@ -50,7 +50,7 @@ type Arr struct {
|
|||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Cleanup bool `json:"cleanup"`
|
Cleanup bool `json:"cleanup"`
|
||||||
SkipRepair bool `json:"skip_repair"`
|
SkipRepair bool `json:"skip_repair"`
|
||||||
DownloadUncached bool `json:"download_uncached"`
|
DownloadUncached *bool `json:"download_uncached"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Repair struct {
|
type Repair struct {
|
||||||
|
|||||||
+2
-2
@@ -31,11 +31,11 @@ type Arr struct {
|
|||||||
Type Type `json:"type"`
|
Type Type `json:"type"`
|
||||||
Cleanup bool `json:"cleanup"`
|
Cleanup bool `json:"cleanup"`
|
||||||
SkipRepair bool `json:"skip_repair"`
|
SkipRepair bool `json:"skip_repair"`
|
||||||
DownloadUncached bool `json:"download_uncached"`
|
DownloadUncached *bool `json:"download_uncached"`
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(name, host, token string, cleanup, skipRepair, downloadUncached bool) *Arr {
|
func New(name, host, token string, cleanup, skipRepair bool, downloadUncached *bool) *Arr {
|
||||||
return &Arr{
|
return &Arr{
|
||||||
Name: name,
|
Name: name,
|
||||||
Host: host,
|
Host: host,
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ func (ad *AllDebrid) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*tor
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if slices.Contains(ad.GetDownloadingStatus(), status) {
|
} else if slices.Contains(ad.GetDownloadingStatus(), status) {
|
||||||
if !ad.DownloadUncached && !torrent.DownloadUncached {
|
if !torrent.DownloadUncached {
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
@@ -280,6 +280,10 @@ func (ad *AllDebrid) GetDownloadingStatus() []string {
|
|||||||
return []string{"downloading"}
|
return []string{"downloading"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ad *AllDebrid) GetDownloadUncached() bool {
|
||||||
|
return ad.DownloadUncached
|
||||||
|
}
|
||||||
|
|
||||||
func New(dc config.Debrid, cache *cache.Cache) *AllDebrid {
|
func New(dc config.Debrid, cache *cache.Cache) *AllDebrid {
|
||||||
rl := request.ParseRateLimit(dc.RateLimit)
|
rl := request.ParseRateLimit(dc.RateLimit)
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
|
|||||||
+18
-7
@@ -47,14 +47,14 @@ func createDebrid(dc config.Debrid, cache *cache.Cache) engine.Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessTorrent(d *engine.Engine, magnet *utils.Magnet, a *arr.Arr, isSymlink, downloadUncached bool) (*torrent.Torrent, error) {
|
func ProcessTorrent(d *engine.Engine, magnet *utils.Magnet, a *arr.Arr, isSymlink, overrideDownloadUncached bool) (*torrent.Torrent, error) {
|
||||||
|
|
||||||
debridTorrent := &torrent.Torrent{
|
debridTorrent := &torrent.Torrent{
|
||||||
InfoHash: magnet.InfoHash,
|
InfoHash: magnet.InfoHash,
|
||||||
Magnet: magnet,
|
Magnet: magnet,
|
||||||
Name: magnet.Name,
|
Name: magnet.Name,
|
||||||
Arr: a,
|
Arr: a,
|
||||||
Size: magnet.Size,
|
Size: magnet.Size,
|
||||||
DownloadUncached: cmp.Or(downloadUncached, a.DownloadUncached),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
@@ -63,6 +63,17 @@ func ProcessTorrent(d *engine.Engine, magnet *utils.Magnet, a *arr.Arr, isSymlin
|
|||||||
logger := db.GetLogger()
|
logger := db.GetLogger()
|
||||||
logger.Info().Msgf("Processing debrid: %s", db.GetName())
|
logger.Info().Msgf("Processing debrid: %s", db.GetName())
|
||||||
|
|
||||||
|
// Override first, arr second, debrid third
|
||||||
|
|
||||||
|
if overrideDownloadUncached {
|
||||||
|
debridTorrent.DownloadUncached = true
|
||||||
|
} else if a.DownloadUncached != nil {
|
||||||
|
// Arr cached is set
|
||||||
|
debridTorrent.DownloadUncached = *a.DownloadUncached
|
||||||
|
} else {
|
||||||
|
debridTorrent.DownloadUncached = db.GetDownloadUncached()
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info().Msgf("Torrent Hash: %s", debridTorrent.InfoHash)
|
logger.Info().Msgf("Torrent Hash: %s", debridTorrent.InfoHash)
|
||||||
if db.GetCheckCached() {
|
if db.GetCheckCached() {
|
||||||
hash, exists := db.IsAvailable([]string{debridTorrent.InfoHash})[debridTorrent.InfoHash]
|
hash, exists := db.IsAvailable([]string{debridTorrent.InfoHash})[debridTorrent.InfoHash]
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ func (dl *DebridLink) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*to
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if slices.Contains(dl.GetDownloadingStatus(), status) {
|
} else if slices.Contains(dl.GetDownloadingStatus(), status) {
|
||||||
if !dl.DownloadUncached && !torrent.DownloadUncached {
|
if !torrent.DownloadUncached {
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
@@ -271,6 +271,10 @@ func (dl *DebridLink) GetCheckCached() bool {
|
|||||||
return dl.CheckCached
|
return dl.CheckCached
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dl *DebridLink) GetDownloadUncached() bool {
|
||||||
|
return dl.DownloadUncached
|
||||||
|
}
|
||||||
|
|
||||||
func New(dc config.Debrid, cache *cache.Cache) *DebridLink {
|
func New(dc config.Debrid, cache *cache.Cache) *DebridLink {
|
||||||
rl := request.ParseRateLimit(dc.RateLimit)
|
rl := request.ParseRateLimit(dc.RateLimit)
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type Service interface {
|
|||||||
DeleteTorrent(tr *torrent.Torrent)
|
DeleteTorrent(tr *torrent.Torrent)
|
||||||
IsAvailable(infohashes []string) map[string]bool
|
IsAvailable(infohashes []string) map[string]bool
|
||||||
GetCheckCached() bool
|
GetCheckCached() bool
|
||||||
|
GetDownloadUncached() bool
|
||||||
GetTorrent(torrent *torrent.Torrent) (*torrent.Torrent, error)
|
GetTorrent(torrent *torrent.Torrent) (*torrent.Torrent, error)
|
||||||
GetTorrents() ([]*torrent.Torrent, error)
|
GetTorrents() ([]*torrent.Torrent, error)
|
||||||
GetName() string
|
GetName() string
|
||||||
|
|||||||
@@ -249,12 +249,9 @@ func (r *RealDebrid) CheckStatus(t *torrent.Torrent, isSymlink bool) (*torrent.T
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if slices.Contains(r.GetDownloadingStatus(), status) {
|
} else if slices.Contains(r.GetDownloadingStatus(), status) {
|
||||||
if !r.DownloadUncached && !t.DownloadUncached {
|
if !t.DownloadUncached {
|
||||||
return t, fmt.Errorf("torrent: %s not cached", t.Name)
|
return t, fmt.Errorf("torrent: %s not cached", t.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
|
|
||||||
} else {
|
} else {
|
||||||
return t, fmt.Errorf("torrent: %s has error: %s", t.Name, status)
|
return t, fmt.Errorf("torrent: %s has error: %s", t.Name, status)
|
||||||
}
|
}
|
||||||
@@ -384,6 +381,10 @@ func (r *RealDebrid) GetDownloadingStatus() []string {
|
|||||||
return []string{"downloading", "magnet_conversion", "queued", "compressing", "uploading"}
|
return []string{"downloading", "magnet_conversion", "queued", "compressing", "uploading"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RealDebrid) GetDownloadUncached() bool {
|
||||||
|
return r.DownloadUncached
|
||||||
|
}
|
||||||
|
|
||||||
func New(dc config.Debrid, cache *cache.Cache) *RealDebrid {
|
func New(dc config.Debrid, cache *cache.Cache) *RealDebrid {
|
||||||
rl := request.ParseRateLimit(dc.RateLimit)
|
rl := request.ParseRateLimit(dc.RateLimit)
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ func (tb *Torbox) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*torren
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if slices.Contains(tb.GetDownloadingStatus(), status) {
|
} else if slices.Contains(tb.GetDownloadingStatus(), status) {
|
||||||
if !tb.DownloadUncached && !torrent.DownloadUncached {
|
if !torrent.DownloadUncached {
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
@@ -332,6 +332,10 @@ func (tb *Torbox) GetTorrents() ([]*torrent.Torrent, error) {
|
|||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tb *Torbox) GetDownloadUncached() bool {
|
||||||
|
return tb.DownloadUncached
|
||||||
|
}
|
||||||
|
|
||||||
func New(dc config.Debrid, cache *cache.Cache) *Torbox {
|
func New(dc config.Debrid, cache *cache.Cache) *Torbox {
|
||||||
rl := request.ParseRateLimit(dc.RateLimit)
|
rl := request.ParseRateLimit(dc.RateLimit)
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
|
|||||||
+2
-1
@@ -59,7 +59,8 @@ func (q *QBit) authContext(next http.Handler) http.Handler {
|
|||||||
// Check if arr exists
|
// Check if arr exists
|
||||||
a := svc.Arr.Get(category)
|
a := svc.Arr.Get(category)
|
||||||
if a == nil {
|
if a == nil {
|
||||||
a = arr.New(category, "", "", false, false, false)
|
downloadUncached := false
|
||||||
|
a = arr.New(category, "", "", false, false, &downloadUncached)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
host = strings.TrimSpace(host)
|
host = strings.TrimSpace(host)
|
||||||
|
|||||||
+1
-1
@@ -311,7 +311,7 @@ func (ui *Handler) handleAddContent(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
_arr := svc.Arr.Get(arrName)
|
_arr := svc.Arr.Get(arrName)
|
||||||
if _arr == nil {
|
if _arr == nil {
|
||||||
_arr = arr.New(arrName, "", "", false, false, false)
|
_arr = arr.New(arrName, "", "", false, false, &downloadUncached)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle URLs
|
// Handle URLs
|
||||||
|
|||||||
Reference in New Issue
Block a user