Repair adjustments 2
This commit is contained in:
@@ -15,9 +15,9 @@ import (
|
||||
// id_trigger: this means a specific torrent id's completion
|
||||
// commands: delete | repair
|
||||
|
||||
func (t *TorrentManager) fixerAddCommand(trigger, command string) {
|
||||
t.log.Debugf("Adding fixer command: %s %s", trigger, command)
|
||||
t.fixers.Set(trigger, command)
|
||||
func (t *TorrentManager) registerFixer(torrentId, command string) {
|
||||
t.log.Debugf("Adding fixer command: %s %s", torrentId, command)
|
||||
t.fixers.Set(torrentId, command)
|
||||
t.writeFixersToFile()
|
||||
}
|
||||
|
||||
@@ -27,59 +27,37 @@ func (t *TorrentManager) processFixers(instances []realdebrid.Torrent) {
|
||||
var toRedownload []*Torrent
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
for _, instance := range instances {
|
||||
id := instance.ID
|
||||
if !t.fixers.Has(id) {
|
||||
if !t.fixers.Has(instance.ID) {
|
||||
continue
|
||||
}
|
||||
command, _ := t.fixers.Pop(id) // delete the fixer if it's done
|
||||
|
||||
oldTorrentId := instance.ID
|
||||
command, _ := t.fixers.Pop(oldTorrentId) // delete the fixer if it's done
|
||||
switch command {
|
||||
|
||||
case "replaced": // id is old torrent id
|
||||
t.log.Debugf("Deleting old id=%s because it's redundant to fixed %s ", id, instance.Name)
|
||||
toDelete = append(toDelete, id)
|
||||
t.log.Debugf("Deleting old id=%s because it's redundant to fixed torrent %s ", oldTorrentId, instance.Name)
|
||||
toDelete = append(toDelete, oldTorrentId)
|
||||
continue
|
||||
|
||||
case "download_failed": // id is failed fixer id
|
||||
t.log.Debugf("Deleting failed fixer id=%s of torrent %s", id, instance.Name)
|
||||
toDelete = append(toDelete, id)
|
||||
t.log.Debugf("Deleting failed fixer id=%s of torrent %s", oldTorrentId, instance.Name)
|
||||
toDelete = append(toDelete, oldTorrentId)
|
||||
continue
|
||||
|
||||
case "repaired": // this torrent contains broken files
|
||||
if instance.Progress != 100 {
|
||||
t.fixers.Set(id, command) // requeue the fixer
|
||||
t.fixers.Set(oldTorrentId, command) // requeue the fixer, it's not done yet
|
||||
continue
|
||||
}
|
||||
|
||||
torrent := t.getMoreInfo(instance)
|
||||
t.log.Debugf("Repairing torrent %s again now that fixer id=%s is done", t.GetKey(torrent), id)
|
||||
repairMe, _ := allTorrents.Get(t.GetKey(torrent))
|
||||
fixedTorrent := t.getMoreInfo(instance)
|
||||
t.log.Debugf("Repairing torrent %s again now that fixer id=%s is done", t.GetKey(fixedTorrent), oldTorrentId)
|
||||
repairMe, _ := allTorrents.Get(t.GetKey(fixedTorrent))
|
||||
toRedownload = append(toRedownload, repairMe)
|
||||
toDelete = append(toDelete, id)
|
||||
toDelete = append(toDelete, oldTorrentId)
|
||||
continue
|
||||
}
|
||||
|
||||
// a new case: repaired_with:<id>
|
||||
// if strings.HasPrefix(command, "repaired_with:") {
|
||||
// if instance.Progress != 100 {
|
||||
// t.fixers.Set(id, command) // requeue the fixer
|
||||
// continue
|
||||
// }
|
||||
// otherId := strings.TrimPrefix(command, "repaired_with:")
|
||||
// for _, instance2 := range instances {
|
||||
// if instance2.ID == otherId {
|
||||
// if instance2.Progress != 100 {
|
||||
// t.fixers.Set(id, command) // requeue the fixer
|
||||
// break
|
||||
// }
|
||||
// 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)
|
||||
// repairMe, _ := allTorrents.Get(t.GetKey(torrent))
|
||||
// toRedownload = append(toRedownload, repairMe)
|
||||
// toDelete = append(toDelete, id, otherId)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// continue
|
||||
// }
|
||||
}
|
||||
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
|
||||
Reference in New Issue
Block a user