Handle repairs
This commit is contained in:
@@ -37,31 +37,26 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
|
||||
freshKeys := mapset.NewSet[string]()
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
toReinsert := mapset.NewSet[string]()
|
||||
noInfoCount := 0
|
||||
for info := range infoChan {
|
||||
if info == nil {
|
||||
noInfoCount++
|
||||
continue
|
||||
}
|
||||
torrentIDs := info.DownloadedIDs.ToSlice()
|
||||
if !info.AnyInProgress() && len(torrentIDs) > 0 && t.onlyForRepair.Contains(info.DownloadedIDs.ToSlice()[0]) {
|
||||
torrentID := info.DownloadedIDs.ToSlice()[0]
|
||||
// if it's 100% and it's a temp repair, remove it
|
||||
t.Api.DeleteTorrent(torrentID)
|
||||
toReinsert.Add(t.GetKey(info))
|
||||
infoChan <- nil
|
||||
t.onlyForRepair.Remove(torrentID)
|
||||
|
||||
accessKey := t.GetKey(info)
|
||||
|
||||
if t.handleRepairTorrents(info) {
|
||||
continue
|
||||
}
|
||||
if !info.AnyInProgress() {
|
||||
freshKeys.Add(t.GetKey(info))
|
||||
freshKeys.Add(accessKey)
|
||||
}
|
||||
if torrent, exists := allTorrents.Get(t.GetKey(info)); !exists {
|
||||
allTorrents.Set(t.GetKey(info), info)
|
||||
if torrent, exists := allTorrents.Get(accessKey); !exists {
|
||||
allTorrents.Set(accessKey, info)
|
||||
} else if !info.DownloadedIDs.Difference(torrent.DownloadedIDs).IsEmpty() {
|
||||
mainTorrent := t.mergeToMain(torrent, info)
|
||||
allTorrents.Set(t.GetKey(info), &mainTorrent)
|
||||
allTorrents.Set(accessKey, &mainTorrent)
|
||||
}
|
||||
}
|
||||
t.log.Infof("Compiled into %d torrents, %d were missing info", allTorrents.Count(), noInfoCount)
|
||||
@@ -94,12 +89,6 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
return false
|
||||
})
|
||||
|
||||
toReinsert.Each(func(accessKey string) bool {
|
||||
torrent, _ := allTorrents.Get(accessKey)
|
||||
t.reinsertTorrent(torrent, "")
|
||||
return false
|
||||
})
|
||||
|
||||
return updatedPaths
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user