Fix issue with bins
This commit is contained in:
@@ -196,7 +196,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
// delete the torrents it replaced
|
||||
torrent.DownloadedIDs.Each(func(torrentID string) bool {
|
||||
if torrentID != info.ID {
|
||||
t.setToBinImmediately(torrentID)
|
||||
t.setToBinOnceDone(fmt.Sprintf("%s-%s", info.ID, torrentID))
|
||||
}
|
||||
return false
|
||||
})
|
||||
@@ -240,9 +240,9 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
batchNum := 1
|
||||
brokenFileIDs := getFileIDs(brokenFiles)
|
||||
var group []string
|
||||
for _, fileIDStr := range brokenFileIDs {
|
||||
for i, fileIDStr := range brokenFileIDs {
|
||||
group = append(group, fileIDStr)
|
||||
if len(group) >= 100 {
|
||||
if len(group) >= 100 || i == len(brokenFileIDs)-1 {
|
||||
t.repairLog.Debugf("Downloading batch %d/%d of broken files of torrent %s", batchNum, totalBatches, t.GetKey(torrent))
|
||||
batchNum++
|
||||
redownloadedInfo, err := t.redownloadTorrent(torrent, group)
|
||||
@@ -259,20 +259,6 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(group) > 0 {
|
||||
t.repairLog.Debugf("Downloading batch %d/%d of broken files of torrent %s", batchNum, totalBatches, t.GetKey(torrent))
|
||||
redownloadedInfo, err := t.redownloadTorrent(torrent, group)
|
||||
if err != nil {
|
||||
t.repairLog.Warnf("Cannot repair torrent %s by downloading broken files (error=%v) giving up", t.GetKey(torrent), err)
|
||||
// delete the newly downloaded torrents because the operation failed
|
||||
for _, newId := range newlyDownloadedIds {
|
||||
t.setToBinImmediately(newId)
|
||||
}
|
||||
return
|
||||
}
|
||||
newlyDownloadedIds = append(newlyDownloadedIds, redownloadedInfo.ID)
|
||||
}
|
||||
|
||||
// once done, we can delete the newly downloaded torrents because we only need the links
|
||||
for _, newId := range newlyDownloadedIds {
|
||||
t.setToBinOnceDone(newId)
|
||||
|
||||
Reference in New Issue
Block a user