Identify broken links properly

This commit is contained in:
Ben Sarmiento
2024-01-11 07:43:27 +01:00
parent 628e3d6345
commit cc37a92d75
6 changed files with 29 additions and 22 deletions

View File

@@ -56,6 +56,7 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
if unrestrict == nil {
log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link)
if cfg.EnableRepair() {
torrent.BrokenLinks.Add(file.Link)
file.Link = "repair"
torMgr.Repair(torrent)
} else {
@@ -159,6 +160,7 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
if file != nil && unrestrict.Streamable == 1 {
log.Warnf("Cannot download file %s: %v", file.Path, err)
if cfg.EnableRepair() && torrent != nil {
torrent.BrokenLinks.Add(file.Link)
file.Link = "repair"
torMgr.Repair(torrent)
} else {
@@ -174,6 +176,7 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
if file != nil && unrestrict.Streamable == 1 {
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
if cfg.EnableRepair() && torrent != nil {
torrent.BrokenLinks.Add(file.Link)
file.Link = "repair"
torMgr.Repair(torrent)
} else {