Simplify bin

This commit is contained in:
Ben Adrian Sarmiento
2024-06-20 06:36:08 +02:00
parent bc04737ca7
commit 340735f833
4 changed files with 36 additions and 84 deletions

View File

@@ -217,7 +217,7 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
t.repairLog.Debugf("Extracting file %s from rar'ed torrent %s", file.Path, t.GetKey(torrent))
info, _ := t.redownloadTorrent(torrent, []string{fmt.Sprintf("%d", file.ID)})
if info != nil {
t.setToBinOnceDone(info.ID)
t.willDeleteOnceDone(info.ID)
}
}
}
@@ -226,7 +226,7 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
t.repairLog.Debugf("Extracting %d video file(s) from rar'ed torrent %s", len(videoFiles), t.GetKey(torrent))
info, _ := t.redownloadTorrent(torrent, videoFiles)
if info != nil {
t.setToBinOnceDone(info.ID)
t.willDeleteOnceDone(info.ID)
}
}
return
@@ -241,14 +241,12 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
info, err := t.redownloadTorrent(torrent, []string{}) // reinsert the whole torrent, passing empty selection
if info != nil && info.Progress == 100 {
if !t.isStillBroken(info, brokenFiles) {
t.repairLog.Infof("Successfully repaired torrent %s by redownloading whole torrent", t.GetKey(torrent))
// delete the torrents it replaced
oldDownloadedIDs.Each(func(torrentID string) bool {
if torrentID != info.ID {
t.setXToBinOnceYDone(torrentID, info.ID)
}
t.DeleteByID(torrentID)
return false
})
t.repairLog.Infof("Successfully repaired torrent %s by redownloading whole torrent", t.GetKey(torrent))
return
}
@@ -308,7 +306,7 @@ func (t *TorrentManager) repair(torrent *Torrent, wg *sync.WaitGroup) {
// once done, we can delete the newly downloaded torrents because we only need the links
for _, newId := range newlyDownloadedIds {
t.setToBinOnceDone(newId)
t.willDeleteOnceDone(newId)
}
}
@@ -418,7 +416,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
t.repairLog.Debugf("Extracting file %s from rar'ed torrent %s", file.Path, t.GetKey(torrent))
info, _ := t.redownloadTorrent(torrent, []string{fmt.Sprintf("%d", file.ID)})
if info != nil {
t.setToBinOnceDone(info.ID)
t.willDeleteOnceDone(info.ID)
}
}
})
@@ -426,7 +424,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
t.repairLog.Debugf("Extracting %d video file(s) from rar'ed torrent %s", len(videoFiles), t.GetKey(torrent))
info, _ := t.redownloadTorrent(torrent, videoFiles)
if info != nil {
t.setToBinOnceDone(info.ID)
t.willDeleteOnceDone(info.ID)
}
}
} else {