mark as unplayable and availability check
This commit is contained in:
@@ -22,11 +22,24 @@ func (t *TorrentManager) RepairAll() {
|
||||
|
||||
func (t *TorrentManager) repairAll() {
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
|
||||
hashes := make([]string, 0)
|
||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||
if torrent.AnyInProgress() || torrent.Unfixable {
|
||||
return
|
||||
}
|
||||
hashes = append(hashes, torrent.Hash)
|
||||
})
|
||||
|
||||
var toRepair []*Torrent
|
||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||
if torrent.AnyInProgress() || torrent.Unfixable {
|
||||
return
|
||||
}
|
||||
|
||||
// check 1: for cached status
|
||||
|
||||
// check 2: for broken files
|
||||
hasBrokenFiles := false
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if file.Link == "repair" || file.Link == "" {
|
||||
@@ -135,11 +148,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
}
|
||||
torrent.SelectedFiles.Set(unassigned.Filename, newFile)
|
||||
}
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
torrents.Remove(torrent.AccessKey)
|
||||
})
|
||||
torrents, _ := t.DirectoryMap.Get(config.UNPLAYABLE_TORRENTS)
|
||||
torrents.Set(torrent.AccessKey, torrent)
|
||||
t.markAsUnplayable(torrent)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -177,7 +186,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||
} else {
|
||||
t.log.Warnf("Failed to repair torrent %s", torrent.AccessKey)
|
||||
torrent.Unfixable = true
|
||||
t.markAsUnplayable(torrent)
|
||||
}
|
||||
} else {
|
||||
t.log.Warnf("Torrent %s has no broken files to repair", torrent.AccessKey)
|
||||
@@ -298,3 +307,13 @@ func (t *TorrentManager) canCapacityHandle() bool {
|
||||
retryCount++
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TorrentManager) markAsUnplayable(torrent *Torrent) {
|
||||
t.log.Warnf("Marking torrent %s as unplayable", torrent.AccessKey)
|
||||
torrent.Unfixable = true
|
||||
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
|
||||
torrents.Remove(torrent.AccessKey)
|
||||
})
|
||||
torrents, _ := t.DirectoryMap.Get(config.UNPLAYABLE_TORRENTS)
|
||||
torrents.Set(torrent.AccessKey, torrent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user