Repairs
This commit is contained in:
@@ -100,6 +100,12 @@ func (t *TorrentManager) repairAll() {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
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
|
||||
@@ -121,17 +127,13 @@ func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
})
|
||||
_ = t.workerPool.Submit(func() {
|
||||
t.log.Infof("Repairing torrent %s", t.GetKey(torrent))
|
||||
torrent.Lock.Lock()
|
||||
defer torrent.Lock.Unlock()
|
||||
torrent.Repairing = true
|
||||
t.repair(torrent)
|
||||
torrent.Repairing = false
|
||||
t.log.Infof("Finished repairing torrent %s", t.GetKey(torrent))
|
||||
})
|
||||
}
|
||||
|
||||
func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
if torrent.AnyInProgress() || torrent.Repairing {
|
||||
if torrent.AnyInProgress() {
|
||||
t.log.Infof("Torrent %s is in progress, skipping repair until download is done", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
@@ -387,14 +389,10 @@ func (t *TorrentManager) markAsUnplayable(torrent *Torrent) {
|
||||
|
||||
func (t *TorrentManager) markAsUnfixable(torrent *Torrent) {
|
||||
t.log.Warnf("Marking torrent %s as unfixable", t.GetKey(torrent))
|
||||
torrent.Lock.Lock()
|
||||
defer torrent.Lock.Unlock()
|
||||
torrent.Unfixable = true
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
info.Lock.Lock()
|
||||
defer info.Lock.Unlock()
|
||||
info.Unfixable = true
|
||||
t.writeTorrentToFile(id, info)
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user