change expired time logic

This commit is contained in:
nikk gitanes
2024-06-04 00:42:49 +03:00
parent 85bc200bf4
commit 785abc38f9

View File

@@ -92,7 +92,7 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
torr.bt = bt torr.bt = bt
torr.closed = goTorrent.Closed() torr.closed = goTorrent.Closed()
torr.TorrentSpec = spec torr.TorrentSpec = spec
torr.AddExpiredTime(time.Minute) torr.AddExpiredTime(time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout))
torr.Timestamp = time.Now().Unix() torr.Timestamp = time.Now().Unix()
go torr.watch() go torr.watch()
@@ -106,8 +106,8 @@ func (t *Torrent) WaitInfo() bool {
return false return false
} }
// Close torrent if not info while 5 minutes // Close torrent if no info in 1 minute + TorrentDisconnectTimeout config option
tm := time.NewTimer(time.Minute * 5) tm := time.NewTimer(time.Minute + time.Second*time.Duration(settings.BTsets.TorrentDisconnectTimeout))
select { select {
case <-t.Torrent.GotInfo(): case <-t.Torrent.GotInfo():
@@ -134,7 +134,7 @@ func (t *Torrent) GotInfo() bool {
t.Stat = state.TorrentGettingInfo t.Stat = state.TorrentGettingInfo
if t.WaitInfo() { if t.WaitInfo() {
t.Stat = state.TorrentWorking t.Stat = state.TorrentWorking
t.AddExpiredTime(time.Minute * 5) t.AddExpiredTime(time.Minute + time.Second*time.Duration(settings.BTsets.TorrentDisconnectTimeout))
return true return true
} else { } else {
t.Close() t.Close()