Full selection is broken, dont redownload it

This commit is contained in:
Ben Sarmiento
2024-02-17 12:41:59 +01:00
parent 46e07f71c4
commit 511dfbb38b
2 changed files with 26 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ package torrent
import ( import (
"io" "io"
"os" "os"
"strings"
"github.com/debridmediamanager/zurg/pkg/realdebrid" "github.com/debridmediamanager/zurg/pkg/realdebrid"
cmap "github.com/orcaman/concurrent-map/v2" cmap "github.com/orcaman/concurrent-map/v2"
@@ -59,30 +58,28 @@ func (t *TorrentManager) processFixers(instances []realdebrid.Torrent) {
} }
// a new case: repaired_with:<id> // a new case: repaired_with:<id>
if strings.HasPrefix(command, "repaired_with:") { // if strings.HasPrefix(command, "repaired_with:") {
if instance.Progress != 100 { // if instance.Progress != 100 {
t.fixers.Set(id, command) // requeue the fixer // t.fixers.Set(id, command) // requeue the fixer
continue // continue
} // }
// otherId := strings.TrimPrefix(command, "repaired_with:")
otherId := strings.TrimPrefix(command, "repaired_with:") // for _, instance2 := range instances {
for _, instance2 := range instances { // if instance2.ID == otherId {
if instance2.ID == otherId { // if instance2.Progress != 100 {
if instance2.Progress != 100 { // t.fixers.Set(id, command) // requeue the fixer
t.fixers.Set(id, command) // requeue the fixer // break
break // }
} // torrent := t.getMoreInfo(instance2)
torrent := t.getMoreInfo(instance2) // t.log.Debugf("Repairing torrent %s again now that fixers ids=%s and %s are done", t.GetKey(torrent), id, otherId)
t.log.Debugf("Repairing torrent %s again now that fixers ids=%s and %s are done", t.GetKey(torrent), id, otherId) // repairMe, _ := allTorrents.Get(t.GetKey(torrent))
repairMe, _ := allTorrents.Get(t.GetKey(torrent)) // toRedownload = append(toRedownload, repairMe)
toRedownload = append(toRedownload, repairMe) // toDelete = append(toDelete, id, otherId)
toDelete = append(toDelete, id, otherId) // break
break // }
} // }
} // continue
// }
continue
}
} }
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE) infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)

View File

@@ -222,6 +222,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
t.log.Infof("Repairing by downloading 2 batches of the broken %d files of torrent %s", len(brokenFiles), t.GetKey(torrent)) t.log.Infof("Repairing by downloading 2 batches of the broken %d files of torrent %s", len(brokenFiles), t.GetKey(torrent))
oldTorrentIDs := torrent.DownloadedIDs.Union(torrent.InProgressIDs).ToSlice()
// divide the broken files into 2 groups // divide the broken files into 2 groups
group1 := make([]*File, 0) group1 := make([]*File, 0)
group2 := make([]*File, 0) group2 := make([]*File, 0)
@@ -246,7 +247,9 @@ func (t *TorrentManager) repair(torrent *Torrent) {
return return
} }
if redownloadedInfo2 != nil { if redownloadedInfo2 != nil {
t.fixerAddCommand(redownloadedInfo2.ID, fmt.Sprintf("repaired_with:%s", redownloadedInfo1.ID)) for _, oldId := range oldTorrentIDs {
t.fixerAddCommand(oldId, "replaced")
}
return return
} }
} }