Return an error for 503
This commit is contained in:
@@ -138,7 +138,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
}
|
||||
|
||||
// proxy function
|
||||
func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool) *realdebrid.Download {
|
||||
func (t *TorrentManager) UnrestrictLink(link string, verifyURL bool) *realdebrid.Download {
|
||||
isRealDebrid := strings.HasPrefix(link, "https://real-debrid.com/d/")
|
||||
if isRealDebrid && t.UnrestrictMap.Has(link[0:39]) {
|
||||
ret, _ := t.UnrestrictMap.Get(link[0:39])
|
||||
@@ -147,7 +147,7 @@ func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool)
|
||||
ret, _ := t.UnrestrictMap.Get(link)
|
||||
return ret
|
||||
}
|
||||
ret, err := t.api.UnrestrictLink(link, checkFirstByte)
|
||||
ret, err := t.api.UnrestrictLink(link, verifyURL)
|
||||
if err != nil {
|
||||
t.log.Warnf("Cannot unrestrict link %s: %v", link, err)
|
||||
return nil
|
||||
@@ -160,11 +160,11 @@ func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool)
|
||||
return ret
|
||||
}
|
||||
|
||||
func (t *TorrentManager) UnrestrictFileUntilOk(file *File, checkFirstByte bool) *realdebrid.Download {
|
||||
func (t *TorrentManager) UnrestrictFile(file *File, checkFirstByte bool) *realdebrid.Download {
|
||||
if !file.State.Is("ok_file") {
|
||||
return nil
|
||||
}
|
||||
return t.UnrestrictLinkUntilOk(file.Link, checkFirstByte)
|
||||
return t.UnrestrictLink(file.Link, checkFirstByte)
|
||||
}
|
||||
|
||||
func (t *TorrentManager) GetKey(torrent *Torrent) string {
|
||||
@@ -235,7 +235,7 @@ func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) {
|
||||
if file.MediaInfo != nil || !file.State.Is("ok_file") || !isPlayable {
|
||||
return
|
||||
}
|
||||
unrestrict := t.UnrestrictFileUntilOk(file, true)
|
||||
unrestrict := t.UnrestrictFile(file, true)
|
||||
if unrestrict == nil {
|
||||
file.State.Event(context.Background(), "break_file")
|
||||
t.EnqueueForRepair(torrent)
|
||||
|
||||
@@ -189,12 +189,12 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
|
||||
return
|
||||
}
|
||||
|
||||
// check for other broken files
|
||||
// check for other broken file
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if !file.State.Is("ok_file") {
|
||||
return
|
||||
}
|
||||
if t.UnrestrictFileUntilOk(file, true) == nil {
|
||||
if t.UnrestrictFile(file, true) == nil {
|
||||
file.State.Event(context.Background(), "break_file")
|
||||
}
|
||||
})
|
||||
@@ -324,7 +324,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
|
||||
|
||||
torrent.UnassignedLinks.Clone().Each(func(link string) bool {
|
||||
// unrestrict each unassigned link that was filled out during torrent init
|
||||
unrestrict := t.UnrestrictLinkUntilOk(link, true)
|
||||
unrestrict := t.UnrestrictLink(link, true)
|
||||
if unrestrict == nil {
|
||||
expiredCount++
|
||||
return false // next unassigned link
|
||||
@@ -653,7 +653,7 @@ func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles
|
||||
// check if the broken files can now be unrestricted and downloaded
|
||||
for _, oldFile := range brokenFiles {
|
||||
for idx, newFile := range selectedFiles {
|
||||
if oldFile.ID == newFile.ID && t.UnrestrictFileUntilOk(selectedFiles[idx], true) == nil {
|
||||
if oldFile.ID == newFile.ID && t.UnrestrictFile(selectedFiles[idx], true) == nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user