Final repair fixes
This commit is contained in:
@@ -17,10 +17,10 @@ const (
|
||||
)
|
||||
|
||||
func (t *TorrentManager) RepairAll() {
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.log.Info("Repairing all broken torrents")
|
||||
_ = t.repairPool.Submit(func() {
|
||||
t.log.Info("Checking for broken torrents")
|
||||
t.repairAll()
|
||||
t.log.Info("Finished repairing all torrents")
|
||||
t.log.Info("Finished checking for broken torrents")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (t *TorrentManager) repairAll() {
|
||||
hashGroups = append(hashGroups, currentGroup)
|
||||
|
||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||
if torrent.AnyInProgress() || torrent.Unfixable {
|
||||
if torrent.AnyInProgress() || torrent.Unrepairable {
|
||||
return
|
||||
}
|
||||
if currentGroup.Cardinality() >= maxGroupSize {
|
||||
@@ -69,7 +69,7 @@ func (t *TorrentManager) repairAll() {
|
||||
|
||||
var toRepair []*Torrent
|
||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||
if torrent.AnyInProgress() || torrent.Unfixable {
|
||||
if torrent.AnyInProgress() || torrent.Unrepairable {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -100,16 +100,15 @@ func (t *TorrentManager) repairAll() {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
if torrent.Unrepairable {
|
||||
t.log.Warnf("Torrent %s is unfixable, skipping repair", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
if repairing, ok := t.Repairs.Get(t.GetKey(torrent)); ok && repairing {
|
||||
t.log.Warnf("Torrent %s is already being repaired, skipping repair", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
t.Repairs.Set(t.GetKey(torrent), true)
|
||||
|
||||
if torrent.Unfixable {
|
||||
t.log.Warnf("Torrent %s is unfixable, skipping repair", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
// save the broken files to the file cache
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
@@ -391,11 +390,11 @@ func (t *TorrentManager) markAsUnplayable(torrent *Torrent) {
|
||||
|
||||
func (t *TorrentManager) markAsUnfixable(torrent *Torrent) {
|
||||
t.log.Warnf("Marking torrent %s as unfixable", t.GetKey(torrent))
|
||||
torrent.Unfixable = true
|
||||
torrent.Unrepairable = true
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
info.Unfixable = true
|
||||
info.Unrepairable = true
|
||||
t.writeTorrentToFile(id, info)
|
||||
return false
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user