Skip to content

Commit

Permalink
change expired time logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Jun 3, 2024
1 parent 85bc200 commit 785abc3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/torr/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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():
Expand All @@ -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()
Expand Down

0 comments on commit 785abc3

Please sign in to comment.