Prevent double repairs

This commit is contained in:
Ben Sarmiento
2023-12-10 22:57:46 +01:00
parent ff72265bfb
commit 74b6ddc99c
4 changed files with 16 additions and 7 deletions

View File

@@ -77,7 +77,7 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
if unrestrict == nil {
log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link)
if cfg.EnableRepair() {
file.Link = "repairing"
file.Link = "repair"
torMgr.Repair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", fileName, link)
@@ -169,7 +169,7 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
if file != nil && unrestrict.Streamable == 1 {
log.Warnf("Cannot download file %s: %v", file.Path, err)
if cfg.EnableRepair() {
file.Link = "repairing"
file.Link = "repair"
torMgr.Repair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)
@@ -184,7 +184,7 @@ func (gf *GetFile) streamFileToResponse(torrent *intTor.Torrent, file *intTor.Fi
if file != nil && unrestrict.Streamable == 1 {
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
if cfg.EnableRepair() {
file.Link = "repairing"
file.Link = "repair"
torMgr.Repair(torrent)
} else {
log.Infof("Repair is disabled, skipping repair for unavailable file %s (link=%s)", file.Path, file.Link)