Fix repairs
This commit is contained in:
@@ -22,12 +22,23 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
infoChan := make(chan *Torrent, len(instances))
|
||||
var wg sync.WaitGroup
|
||||
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
for i := range instances {
|
||||
idx := i
|
||||
wg.Add(1)
|
||||
_ = t.workerPool.Submit(func() {
|
||||
defer wg.Done()
|
||||
infoChan <- t.getMoreInfo(instances[idx])
|
||||
if instances[idx].Progress == 100 && t.onlyForRepair.Has(instances[idx].ID) {
|
||||
torrent, _ := t.onlyForRepair.Get(instances[idx].ID)
|
||||
brokenFiles := getBrokenFiles(torrent)
|
||||
info, err := t.redownloadTorrent(torrent, "")
|
||||
if err == nil && info.Progress == 100 && !t.isStillBroken(info, brokenFiles) {
|
||||
t.onlyForRepair.Remove(instances[idx].ID)
|
||||
}
|
||||
infoChan <- nil
|
||||
} else {
|
||||
infoChan <- t.getMoreInfo(instances[idx])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,19 +47,13 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
t.log.Debugf("Fetched info for %d torrents", len(instances))
|
||||
|
||||
freshKeys := mapset.NewSet[string]()
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
noInfoCount := 0
|
||||
for info := range infoChan {
|
||||
if info == nil {
|
||||
noInfoCount++
|
||||
continue
|
||||
}
|
||||
|
||||
accessKey := t.GetKey(info)
|
||||
|
||||
if t.handleRepairTorrents(info) {
|
||||
continue
|
||||
}
|
||||
if !info.AnyInProgress() {
|
||||
freshKeys.Add(accessKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user