Repair logs
This commit is contained in:
@@ -43,7 +43,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
noInfoCount++
|
||||
continue
|
||||
}
|
||||
if !info.AnyInProgress() {
|
||||
if !info.AllInProgress() {
|
||||
freshKeys.Add(info.AccessKey)
|
||||
}
|
||||
if torrent, exists := allTorrents.Get(info.AccessKey); !exists {
|
||||
@@ -76,6 +76,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
||||
return true
|
||||
})
|
||||
// removed torrents
|
||||
// items which are in in t.allAccessKeys but not in freshKeys
|
||||
strset.Difference(t.allAccessKeys, freshKeys).Each(func(accessKey string) bool {
|
||||
t.Delete(accessKey, false)
|
||||
return true
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -80,7 +80,7 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
} else {
|
||||
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", fileName, link)
|
||||
}
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
@@ -172,7 +172,7 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
} else {
|
||||
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
|
||||
}
|
||||
}
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
@@ -187,7 +187,7 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
} else {
|
||||
log.Info("Repair is disabled, skipping repair for unavailable file")
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
|
||||
}
|
||||
}
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
|
||||
Reference in New Issue
Block a user