Repair logs

This commit is contained in:
Ben Sarmiento
2023-12-10 18:45:26 +01:00
parent 788e19de8f
commit fef347425e
3 changed files with 12 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ func (t *TorrentManager) repairAll() {
var toRepair []*Torrent
allTorrents.IterCb(func(_ string, torrent *Torrent) {
if torrent.AnyInProgress() && torrent.ForRepair {
t.log.Warnf("Skipping %s for repairs because it is in progress", torrent.AccessKey)
t.log.Warnf("Skipping %s for repairs because it is still in progress", torrent.AccessKey)
return
} else if torrent.ForRepair && !torrent.Unfixable {
toRepair = append(toRepair, torrent)
@@ -57,16 +57,19 @@ func (t *TorrentManager) repair(torrent *Torrent) {
if torrent.OlderThanDuration(EXPIRED_LINK_TOLERANCE_HOURS * time.Hour) {
// first solution: reinsert with same selection
t.log.Infof("Torrent %s is older than %d hours, reinserting it", torrent.AccessKey, EXPIRED_LINK_TOLERANCE_HOURS)
if t.reinsertTorrent(torrent, "") {
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
return
} else {
t.log.Warn("Failed to repair by reinserting torrent")
t.log.Warnf("Failed to repair by reinserting torrent %s", torrent.AccessKey)
}
} else {
t.log.Infof("Torrent %s is not older than %d hours to be repaired by reinsertion, skipping", torrent.AccessKey, EXPIRED_LINK_TOLERANCE_HOURS)
t.log.Warnf("Torrent %s is not older than %d hours to be repaired by reinsertion", torrent.AccessKey, EXPIRED_LINK_TOLERANCE_HOURS)
}
// sleep for 30 seconds to let the torrent accumulate more broken files if scanning
time.Sleep(30 * time.Second)
// second solution: add only the missing files
var missingFiles []File
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
@@ -74,6 +77,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
missingFiles = append(missingFiles, *file)
}
})
t.log.Debugf("During repair, zurg found %d broken files for torrent %s", len(missingFiles), torrent.AccessKey)
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)