Repair edge cases

This commit is contained in:
Ben Sarmiento
2024-01-19 04:22:56 +01:00
parent 6c7c57ebfa
commit ccd260db6a
5 changed files with 16 additions and 9 deletions

View File

@@ -242,6 +242,10 @@ func (t *TorrentManager) repair(torrent *Torrent) {
t.log.Infof("Successfully repaired torrent %s using repair_method#1", t.GetKey(torrent))
return
}
if info != nil && info.ID != "" {
t.log.Warnf("Torrent %s is still broken after repair_method#1, cleaning up", t.GetKey(torrent))
t.Api.DeleteTorrent(info.ID)
}
// second solution: add only the broken files
if len(brokenFiles) > 0 {
@@ -258,7 +262,6 @@ func (t *TorrentManager) repair(torrent *Torrent) {
}
func (t *TorrentManager) redownloadTorrent(torrent *Torrent, brokenFiles string) (*realdebrid.TorrentInfo, error) {
t.log.Debugf("Redownloading torrent %s, broken files=%s (all if empty)", t.GetKey(torrent), brokenFiles)
oldTorrentIDs := make([]string, 0)
// broken files means broken links
// if brokenFiles is not provided
@@ -424,7 +427,7 @@ func getBrokenFiles(torrent *Torrent) []*File {
func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles []*File) bool {
for _, oldFile := range brokenFiles {
for idx, newFile := range info.Files {
if oldFile.Path == newFile.Path {
if oldFile.Path == newFile.Path || oldFile.Bytes == newFile.Bytes {
unrestrict := t.UnrestrictUntilOk(info.Links[idx])
if unrestrict == nil || oldFile.Bytes != unrestrict.Filesize {
return true