Delete in progress fixers
This commit is contained in:
@@ -106,7 +106,6 @@ func (t *TorrentManager) repairAll(torrent *Torrent) {
|
||||
}
|
||||
})
|
||||
if brokenFileIDs.Cardinality() > 0 {
|
||||
t.log.Debugf("Torrent %s has %d broken files (ids=%v), adding to repair list", t.GetKey(torrent), brokenFileIDs.Cardinality(), brokenFileIDs.ToSlice())
|
||||
toRepair.Add(torrent)
|
||||
return
|
||||
}
|
||||
@@ -166,18 +165,19 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
|
||||
// get all broken files
|
||||
brokenFiles := getBrokenFiles(torrent)
|
||||
t.log.Debugf("Torrent %s has %d broken files (total is %d)", t.GetKey(torrent), len(brokenFiles), torrent.SelectedFiles.Count())
|
||||
brokenFileIDs := getFileIDs(brokenFiles)
|
||||
t.log.Debugf("Torrent %s has %d broken files (ids=%s; total is %d), repairing by redownloading", t.GetKey(torrent), len(brokenFiles), brokenFileIDs, torrent.SelectedFiles.Count())
|
||||
|
||||
// first step: redownload the whole torrent
|
||||
t.log.Debugf("Repairing torrent %s by redownloading", t.GetKey(torrent))
|
||||
info, err := t.redownloadTorrent(torrent, "") // reinsert the torrent, passing ""
|
||||
if err != nil {
|
||||
t.log.Warnf("Cannot repair torrent %s by redownloading (error=%s)", t.GetKey(torrent), err.Error())
|
||||
} else if info != nil && info.Progress != 100 {
|
||||
t.log.Infof("Torrent %s is still in progress after redownloading but it should be repaired once done", t.GetKey(torrent))
|
||||
torrent.InProgressIDs.Add(info.ID)
|
||||
t.saveTorrentChangesToDisk(torrent, nil)
|
||||
t.log.Infof("Torrent %s (files=%s) is still in progress after redownloading but it should be repaired once done", t.GetKey(torrent), brokenFileIDs)
|
||||
return
|
||||
} else if info != nil && info.IsDone() && !t.isStillBroken(info, brokenFiles) {
|
||||
} else if info != nil && info.Progress == 100 && !t.isStillBroken(info, brokenFiles) {
|
||||
selectedFiles := getSelectedFiles(info)
|
||||
torrent.SelectedFiles.IterCb(func(_ string, oldFile *File) {
|
||||
for _, newFile := range selectedFiles {
|
||||
@@ -190,7 +190,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
})
|
||||
torrent.DownloadedIDs.Add(info.ID)
|
||||
t.saveTorrentChangesToDisk(torrent, nil)
|
||||
t.log.Infof("Successfully repaired torrent %s by redownloading", t.GetKey(torrent))
|
||||
t.log.Infof("Successfully repaired torrent %s (files=%s) by redownloading", t.GetKey(torrent), brokenFileIDs)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user