Repair logs
This commit is contained in:
@@ -43,7 +43,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
|||||||
noInfoCount++
|
noInfoCount++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !info.AnyInProgress() {
|
if !info.AllInProgress() {
|
||||||
freshKeys.Add(info.AccessKey)
|
freshKeys.Add(info.AccessKey)
|
||||||
}
|
}
|
||||||
if torrent, exists := allTorrents.Get(info.AccessKey); !exists {
|
if torrent, exists := allTorrents.Get(info.AccessKey); !exists {
|
||||||
@@ -76,6 +76,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
// removed torrents
|
// removed torrents
|
||||||
|
// items which are in in t.allAccessKeys but not in freshKeys
|
||||||
strset.Difference(t.allAccessKeys, freshKeys).Each(func(accessKey string) bool {
|
strset.Difference(t.allAccessKeys, freshKeys).Each(func(accessKey string) bool {
|
||||||
t.Delete(accessKey, false)
|
t.Delete(accessKey, false)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func (t *TorrentManager) repairAll() {
|
|||||||
var toRepair []*Torrent
|
var toRepair []*Torrent
|
||||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||||
if torrent.AnyInProgress() && torrent.ForRepair {
|
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
|
return
|
||||||
} else if torrent.ForRepair && !torrent.Unfixable {
|
} else if torrent.ForRepair && !torrent.Unfixable {
|
||||||
toRepair = append(toRepair, torrent)
|
toRepair = append(toRepair, torrent)
|
||||||
@@ -57,16 +57,19 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
|||||||
|
|
||||||
if torrent.OlderThanDuration(EXPIRED_LINK_TOLERANCE_HOURS * time.Hour) {
|
if torrent.OlderThanDuration(EXPIRED_LINK_TOLERANCE_HOURS * time.Hour) {
|
||||||
// first solution: reinsert with same selection
|
// 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, "") {
|
if t.reinsertTorrent(torrent, "") {
|
||||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
t.log.Warn("Failed to repair by reinserting torrent")
|
t.log.Warnf("Failed to repair by reinserting torrent %s", torrent.AccessKey)
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
// second solution: add only the missing files
|
||||||
var missingFiles []File
|
var missingFiles []File
|
||||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||||
@@ -74,6 +77,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
|||||||
missingFiles = append(missingFiles, *file)
|
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 {
|
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)
|
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"
|
file.Link = "repairing"
|
||||||
torMgr.Repair(torrent)
|
torMgr.Repair(torrent)
|
||||||
} else {
|
} 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)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
@@ -172,7 +172,7 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
|||||||
file.Link = "repairing"
|
file.Link = "repairing"
|
||||||
torMgr.Repair(torrent)
|
torMgr.Repair(torrent)
|
||||||
} else {
|
} 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)
|
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"
|
file.Link = "repairing"
|
||||||
torMgr.Repair(torrent)
|
torMgr.Repair(torrent)
|
||||||
} else {
|
} 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)
|
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||||
|
|||||||
Reference in New Issue
Block a user