From 96fd72ba880959367da0b64c71421f313ce8bdc4 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 28 Apr 2024 11:06:01 +0200 Subject: [PATCH] Repair adjustments --- internal/torrent/repair.go | 1 + pkg/http/client.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/torrent/repair.go b/internal/torrent/repair.go index 9869e13..5c16bb8 100644 --- a/internal/torrent/repair.go +++ b/internal/torrent/repair.go @@ -262,6 +262,7 @@ func (t *TorrentManager) repair(torrent *Torrent) { } func (t *TorrentManager) assignUnassignedLinks(torrent *Torrent) bool { + t.log.Infof("Trying to assign links to incomplete torrent %s", t.GetKey(torrent)) // handle torrents with incomplete links for selected files assignedCount := 0 rarCount := 0 diff --git a/pkg/http/client.go b/pkg/http/client.go index 0848527..dc77c22 100644 --- a/pkg/http/client.go +++ b/pkg/http/client.go @@ -319,14 +319,14 @@ func backoffFunc(attempt int) time.Duration { } func (r *HTTPClient) CanFetchFirstByte(url string) bool { - timeout := time.Duration(r.timeoutSecs) * time.Second - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() req, err := http.NewRequest("GET", url, nil) if err != nil { return false } req.Header.Set("Range", "bytes=0-0") + timeout := time.Duration(r.timeoutSecs) * time.Second + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() req = req.WithContext(ctx) resp, err := r.Do(req)