Hotfix on repairs
This commit is contained in:
@@ -581,13 +581,13 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
return
|
||||
}
|
||||
|
||||
// first solution: add the same selection, maybe it can be fixed by reinsertion?
|
||||
// first solution: reinsert with same selection
|
||||
if t.reinsertTorrent(torrent, "") {
|
||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||
return
|
||||
}
|
||||
|
||||
// if all the selected files are missing but there are other streamable files
|
||||
// second solution: add only the missing files
|
||||
var missingFiles []File
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if !strings.HasPrefix(file.Link, "http") {
|
||||
@@ -629,14 +629,11 @@ func (t *TorrentManager) reinsertTorrent(torrent *Torrent, missingFiles string)
|
||||
if missingFiles == "" {
|
||||
tmpSelection := ""
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if !strings.HasPrefix(file.Link, "http") {
|
||||
tmpSelection += fmt.Sprintf("%d,", file.ID)
|
||||
}
|
||||
tmpSelection += fmt.Sprintf("%d,", file.ID) // select all files
|
||||
})
|
||||
if tmpSelection == "" {
|
||||
return false
|
||||
}
|
||||
if len(tmpSelection) > 0 {
|
||||
return true // nothing to repair
|
||||
} else {
|
||||
missingFiles = tmpSelection[:len(tmpSelection)-1]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user