periodic repair

This commit is contained in:
Ben Sarmiento
2024-01-27 14:14:11 +01:00
parent 05d2544fe8
commit a851282b2a
7 changed files with 97 additions and 19 deletions

View File

@@ -57,9 +57,9 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
torrent.BrokenLinks.Add(file.Link)
// file.Link = "repair"
if cfg.EnableRepair() {
torMgr.SetNewLatestState(intTor.LibraryState{})
torMgr.TriggerRepair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", fileName, link)
log.Debugf("Repair is disabled, skipping repair for unavailable file %s (link=%s)", fileName, link)
}
http.Error(resp, "File is not available", http.StatusNotFound)
return
@@ -167,9 +167,9 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
torrent.BrokenLinks.Add(file.Link)
// file.Link = "repair"
if cfg.EnableRepair() && torrent != nil {
torMgr.SetNewLatestState(intTor.LibraryState{})
torMgr.TriggerRepair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
log.Debugf("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
}
}
http.Error(resp, "File is not available", http.StatusNotFound)
@@ -184,9 +184,9 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
torrent.BrokenLinks.Add(file.Link)
// file.Link = "repair"
if cfg.EnableRepair() && torrent != nil {
torMgr.SetNewLatestState(intTor.LibraryState{})
torMgr.TriggerRepair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
log.Debugf("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
}
}
http.Error(resp, "File is not available", http.StatusNotFound)
@@ -199,7 +199,7 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
}
}
log.Infof("Started serving file %s%s", unrestrict.Filename, rangeLog)
log.Debugf("Started serving file %s%s", unrestrict.Filename, rangeLog)
buf := make([]byte, cfg.GetNetworkBufferSize())
io.CopyBuffer(resp, download.Body, buf)