Prevent double repairs
This commit is contained in:
@@ -36,6 +36,12 @@ func (t *TorrentManager) repairAll() {
|
||||
}
|
||||
|
||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
infoCache.Set(id, torrent)
|
||||
t.writeTorrentToFile(id, torrent)
|
||||
return true
|
||||
})
|
||||
_ = t.repairWorker.Submit(func() {
|
||||
t.log.Infof("Repairing torrent %s", torrent.AccessKey)
|
||||
t.repair(torrent)
|
||||
@@ -73,8 +79,9 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
// second solution: add only the missing files
|
||||
var missingFiles []File
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if !strings.HasPrefix(file.Link, "http") {
|
||||
if file.Link == "repair" || file.Link == "" {
|
||||
missingFiles = append(missingFiles, *file)
|
||||
file.Link = "repairing"
|
||||
}
|
||||
})
|
||||
t.log.Debugf("During repair, zurg found %d broken files for torrent %s", len(missingFiles), torrent.AccessKey)
|
||||
|
||||
Reference in New Issue
Block a user