From 785abc38f90ba28554bd8ac86860df266087fe6f Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Tue, 4 Jun 2024 00:42:49 +0300 Subject: [PATCH] change expired time logic --- server/torr/torrent.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 733d64c..b38332c 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -92,7 +92,7 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) { torr.bt = bt torr.closed = goTorrent.Closed() torr.TorrentSpec = spec - torr.AddExpiredTime(time.Minute) + torr.AddExpiredTime(time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout)) torr.Timestamp = time.Now().Unix() go torr.watch() @@ -106,8 +106,8 @@ func (t *Torrent) WaitInfo() bool { return false } - // Close torrent if not info while 5 minutes - tm := time.NewTimer(time.Minute * 5) + // Close torrent if no info in 1 minute + TorrentDisconnectTimeout config option + tm := time.NewTimer(time.Minute + time.Second*time.Duration(settings.BTsets.TorrentDisconnectTimeout)) select { case <-t.Torrent.GotInfo(): @@ -134,7 +134,7 @@ func (t *Torrent) GotInfo() bool { t.Stat = state.TorrentGettingInfo if t.WaitInfo() { t.Stat = state.TorrentWorking - t.AddExpiredTime(time.Minute * 5) + t.AddExpiredTime(time.Minute + time.Second*time.Duration(settings.BTsets.TorrentDisconnectTimeout)) return true } else { t.Close()