A more efficient repair procedure
This commit is contained in:
@@ -67,7 +67,8 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
|
||||
unrestrict := torMgr.UnrestrictUntilOk(link)
|
||||
if unrestrict == nil {
|
||||
// log.Warnf("File %s is no longer available, link %s", filepath.Base(file.Path), link)
|
||||
file.Link = "repair"
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
torMgr.UpdateTorrentResponseCache(torrent)
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
@@ -148,7 +149,8 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
||||
if err != nil {
|
||||
if file != nil {
|
||||
log.Warnf("Cannot download file %s: %v", file.Path, err)
|
||||
file.Link = "repair"
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
torMgr.UpdateTorrentResponseCache(torrent)
|
||||
}
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
@@ -159,7 +161,8 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
|
||||
if download.StatusCode != http.StatusOK && download.StatusCode != http.StatusPartialContent {
|
||||
if file != nil {
|
||||
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
|
||||
file.Link = "repair"
|
||||
file.Link = "repairing"
|
||||
torMgr.Repair(torrent)
|
||||
torMgr.UpdateTorrentResponseCache(torrent)
|
||||
}
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
|
||||
Reference in New Issue
Block a user