Unrepairable hotfix
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const EXPIRED_LINK_TOLERANCE_HOURS = 24
|
||||
|
||||
func (t *TorrentManager) RepairAll() {
|
||||
_ = t.repairWorker.Submit(func() {
|
||||
t.repairAll()
|
||||
@@ -53,8 +55,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
return
|
||||
}
|
||||
|
||||
expiredLinkTolerance := 24 * time.Hour
|
||||
if torrent.OlderThanDuration(expiredLinkTolerance) {
|
||||
if torrent.OlderThanDuration(EXPIRED_LINK_TOLERANCE_HOURS * time.Hour) {
|
||||
// first solution: reinsert with same selection
|
||||
if t.reinsertTorrent(torrent, "") {
|
||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||
@@ -63,7 +64,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
t.log.Warn("Failed to repair by reinserting torrent")
|
||||
}
|
||||
} else {
|
||||
t.log.Infof("Torrent %s is not older than %d hours to be repaired by reinsertion, skipping", torrent.AccessKey, expiredLinkTolerance.Hours())
|
||||
t.log.Infof("Torrent %s is not older than %d hours to be repaired by reinsertion, skipping", torrent.AccessKey, EXPIRED_LINK_TOLERANCE_HOURS)
|
||||
}
|
||||
|
||||
// second solution: add only the missing files
|
||||
@@ -74,10 +75,13 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
}
|
||||
})
|
||||
|
||||
// if we download a single file, it will be named differently
|
||||
// so we need to download 1 extra file to preserve the name
|
||||
// this is only relevant if we enable retain_rd_torrent_name
|
||||
if len(missingFiles) == 1 && torrent.SelectedFiles.Count() > 1 {
|
||||
if len(missingFiles) == 1 && torrent.SelectedFiles.Count() == 1 {
|
||||
t.log.Warnf("Torrent %s is unrepairable, the lone file is expired but still cached in Real-Debrid", torrent.AccessKey)
|
||||
return
|
||||
} else if len(missingFiles) == 1 && torrent.SelectedFiles.Count() > 1 {
|
||||
// if we download a single file, it will be named differently
|
||||
// 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
|
||||
for _, file := range torrent.SelectedFiles.Items() {
|
||||
if strings.HasPrefix(file.Link, "http") {
|
||||
|
||||
Reference in New Issue
Block a user