Repair logic
This commit is contained in:
@@ -37,12 +37,22 @@ 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
|
||||
}
|
||||
torrentID := info.DownloadedIDs.ToSlice()[0]
|
||||
if !info.AnyInProgress() && t.forRepairs.Contains(torrentID) {
|
||||
// if it's 100% and it's a temp repair, remove it
|
||||
t.Api.DeleteTorrent(torrentID)
|
||||
toReinsert.Add(t.GetKey(info))
|
||||
infoChan <- nil
|
||||
t.forRepairs.Remove(torrentID)
|
||||
continue
|
||||
}
|
||||
if !info.AnyInProgress() {
|
||||
freshKeys.Add(t.GetKey(info))
|
||||
}
|
||||
@@ -54,6 +64,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
}
|
||||
}
|
||||
t.log.Infof("Compiled into %d torrents, %d were missing info", allTorrents.Count(), noInfoCount)
|
||||
|
||||
var updatedPaths []string
|
||||
// torrents yet to be assigned in a directory
|
||||
freshKeys.Difference(t.allAccessKeys).Each(func(accessKey string) bool {
|
||||
@@ -82,6 +93,12 @@ 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