Verify if downloadable

This commit is contained in:
Ben Sarmiento
2024-05-25 16:02:18 +02:00
parent b8c67a83cf
commit 7886ed69a2
3 changed files with 22 additions and 22 deletions

View File

@@ -177,7 +177,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
if !file.State.Is("ok_file") {
return
}
if t.UnrestrictFileUntilOk(file) == nil {
if t.UnrestrictFileUntilOk(file, true) == nil {
file.State.Event(context.Background(), "break_file")
}
})
@@ -292,7 +292,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
torrent.UnassignedLinks.Each(func(link string) bool {
// unrestrict each unassigned link that was filled out during torrent init
unrestrict := t.UnrestrictLinkUntilOk(link)
unrestrict := t.UnrestrictLinkUntilOk(link, true)
if unrestrict == nil {
expiredCount++
return false // next unassigned link
@@ -393,19 +393,6 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string)
prevState := t.latestState
resp, err := t.api.AddMagnetHash(torrent.Hash)
if err != nil {
if strings.Contains(err.Error(), "infringing") {
t.markAsUnfixable(torrent, "infringing torrent")
} else if strings.Contains(err.Error(), "unsupported") {
t.markAsUnfixable(torrent, "unsupported torrent")
} else if strings.Contains(err.Error(), "unavailable") {
t.markAsUnfixable(torrent, "unavailable torrent")
} else if strings.Contains(err.Error(), "invalid") {
t.markAsUnfixable(torrent, "invalid torrent")
} else if strings.Contains(err.Error(), "big") {
t.markAsUnfixable(torrent, "torrent too big")
} else if strings.Contains(err.Error(), "allowed") {
t.markAsUnfixable(torrent, "torrent not allowed")
}
if strings.Contains(err.Error(), "timeout") {
newState := t.getCurrentState()
if prevState.Eq(newState) {
@@ -413,6 +400,19 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string)
}
newTorrentID = t.latestState.FirstTorrentId
} else {
if strings.Contains(err.Error(), "infringing") {
t.markAsUnfixable(torrent, "infringing torrent")
} else if strings.Contains(err.Error(), "unsupported") {
t.markAsUnfixable(torrent, "unsupported torrent")
} else if strings.Contains(err.Error(), "unavailable") {
t.markAsUnfixable(torrent, "unavailable torrent")
} else if strings.Contains(err.Error(), "invalid") {
t.markAsUnfixable(torrent, "invalid torrent")
} else if strings.Contains(err.Error(), "big") {
t.markAsUnfixable(torrent, "torrent too big")
} else if strings.Contains(err.Error(), "allowed") {
t.markAsUnfixable(torrent, "torrent not allowed")
}
return nil, fmt.Errorf("cannot add magnet of torrent %s (hash=%s): %v", t.GetKey(torrent), torrent.Hash, err)
}
}
@@ -590,7 +590,7 @@ func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles
// check if the broken files can now be unrestricted
for _, oldFile := range brokenFiles {
for idx, newFile := range selectedFiles {
if oldFile.ID == newFile.ID && t.UnrestrictFileUntilOk(selectedFiles[idx]) == nil {
if oldFile.ID == newFile.ID && t.UnrestrictFileUntilOk(selectedFiles[idx], true) == nil {
return true
}
}