Do not repair if uncached check fails
This commit is contained in:
@@ -54,9 +54,9 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
|
||||
unrestrict := torMgr.UnrestrictUntilOk(link)
|
||||
if unrestrict == nil {
|
||||
log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link)
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
if cfg.EnableRepair() {
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", fileName, link)
|
||||
@@ -166,9 +166,9 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
if err != nil {
|
||||
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
||||
if file != nil && unrestrict.Streamable == 1 {
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
if cfg.EnableRepair() && torrent != nil {
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
|
||||
@@ -177,14 +177,13 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
defer download.Body.Close()
|
||||
|
||||
if download.StatusCode != http.StatusOK && download.StatusCode != http.StatusPartialContent {
|
||||
if file != nil && unrestrict.Streamable == 1 {
|
||||
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
if cfg.EnableRepair() && torrent != nil {
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
|
||||
|
||||
Reference in New Issue
Block a user