Surefire way of no dupes
This commit is contained in:
@@ -297,6 +297,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, brokenFiles string)
|
||||
err = t.Api.SelectTorrentFiles(newTorrentID, brokenFiles)
|
||||
if err != nil {
|
||||
t.Api.DeleteTorrent(newTorrentID)
|
||||
t.fixers.Set(newTorrentID, torrent)
|
||||
return nil, fmt.Errorf("cannot start redownloading: %v", err)
|
||||
}
|
||||
|
||||
@@ -304,6 +305,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, brokenFiles string)
|
||||
info, err := t.Api.GetTorrentInfo(newTorrentID)
|
||||
if err != nil {
|
||||
t.Api.DeleteTorrent(newTorrentID)
|
||||
t.fixers.Set(newTorrentID, torrent)
|
||||
return nil, fmt.Errorf("cannot get info on redownloaded torrent %s (id=%s) : %v", t.GetKey(torrent), newTorrentID, err)
|
||||
}
|
||||
|
||||
@@ -319,6 +321,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, brokenFiles string)
|
||||
}
|
||||
if !isOkStatus {
|
||||
t.Api.DeleteTorrent(newTorrentID)
|
||||
t.fixers.Set(newTorrentID, torrent)
|
||||
return nil, fmt.Errorf("the redownloaded torrent %s (id=%s) is in error state: %s", t.GetKey(torrent), newTorrentID, info.Status)
|
||||
}
|
||||
|
||||
@@ -337,6 +340,7 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, brokenFiles string)
|
||||
brokenCount := len(strings.Split(brokenFiles, ","))
|
||||
if len(info.Links) != brokenCount {
|
||||
t.Api.DeleteTorrent(newTorrentID)
|
||||
t.fixers.Set(newTorrentID, torrent)
|
||||
return nil, fmt.Errorf("it did not fix the issue for %s (id=%s), only got %d files but we need %d, undoing", t.GetKey(torrent), info.ID, len(info.Links), brokenCount)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user