A more efficient repair procedure

This commit is contained in:
Ben Sarmiento
2023-12-02 02:43:47 +01:00
parent b5a923fd17
commit 1cb80e5047
2 changed files with 115 additions and 125 deletions

View File

@@ -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)