Torrent repair fix
This commit is contained in:
@@ -94,6 +94,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
// so we need to download 1 extra file to preserve the name
|
||||
// this is only relevant if we enable retain_rd_torrent_name
|
||||
// add the first file link encountered with a prefix of http
|
||||
t.log.Debugf("Torrent %s has only 1 missing file, adding 1 extra file to preserve the name", torrent.AccessKey)
|
||||
for _, file := range torrent.SelectedFiles.Items() {
|
||||
if strings.HasPrefix(file.Link, "http") {
|
||||
missingFiles = append(missingFiles, *file)
|
||||
@@ -102,17 +103,9 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
}
|
||||
}
|
||||
if len(missingFiles) > 0 {
|
||||
t.log.Infof("Redownloading in multiple batches the %d missing files for torrent %s", len(missingFiles), torrent.AccessKey)
|
||||
// if not, last resort: add only the missing files but do it in 2 batches
|
||||
half := len(missingFiles) / 2
|
||||
missingFiles1 := strings.Join(getFileIDs(missingFiles[:half]), ",")
|
||||
missingFiles2 := strings.Join(getFileIDs(missingFiles[half:]), ",")
|
||||
if missingFiles1 != "" {
|
||||
t.reinsertTorrent(torrent, missingFiles1)
|
||||
}
|
||||
if missingFiles2 != "" {
|
||||
t.reinsertTorrent(torrent, missingFiles2)
|
||||
}
|
||||
t.log.Infof("Redownloading the %d missing files for torrent %s", len(missingFiles), torrent.AccessKey)
|
||||
missingFileIDs := strings.Join(getFileIDs(missingFiles), ",")
|
||||
t.reinsertTorrent(torrent, missingFileIDs)
|
||||
} else {
|
||||
t.log.Warnf("Torrent %s has no missing files to repair", torrent.AccessKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user